chore: use markets only in market selector, change Instrument cache policy

This commit is contained in:
Bartłomiej Głownia 2022-09-19 14:12:39 +02:00
parent e8034b91ae
commit 84d1511972
3 changed files with 11 additions and 5 deletions

View File

@ -23,7 +23,6 @@ describe('market selector', () => {
aliasQuery(req, 'Markets', generateSimpleMarkets()); aliasQuery(req, 'Markets', generateSimpleMarkets());
aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles());
aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); aliasQuery(req, 'MarketsDataQuery', generateMarketsData());
aliasQuery(req, 'Markets', generateSimpleMarkets());
aliasQuery(req, 'DealTicketQuery', generateDealTicket()); aliasQuery(req, 'DealTicketQuery', generateDealTicket());
aliasQuery(req, 'MarketTags', generateMarketTags()); aliasQuery(req, 'MarketTags', generateMarketTags());
aliasQuery(req, 'MarketPositions', generateMarketPositions()); aliasQuery(req, 'MarketPositions', generateMarketPositions());
@ -68,7 +67,7 @@ describe('market selector', () => {
} }
}); });
it('typing should change list', () => { it.only('typing should change list', () => {
if (markets?.length) { if (markets?.length) {
cy.visit(`/trading/${markets[0].id}`); cy.visit(`/trading/${markets[0].id}`);
connectVegaWallet(); connectVegaWallet();

View File

@ -38,6 +38,9 @@ export function createClient(base?: string) {
Node: { Node: {
keyFields: false, keyFields: false,
}, },
Instrument: {
keyFields: false,
},
}, },
}); });

View File

@ -20,11 +20,12 @@ import {
t, t,
useScreenDimensions, useScreenDimensions,
useOutsideClick, useOutsideClick,
useDataProvider,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { IconNames } from '@blueprintjs/icons'; import { IconNames } from '@blueprintjs/icons';
import { MarketState } from '@vegaprotocol/types'; import { MarketState } from '@vegaprotocol/types';
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
import { useMarketList } from '@vegaprotocol/market-list'; import { marketsProvider } from '@vegaprotocol/market-list';
interface Props { interface Props {
market: DealTicketQuery_market; market: DealTicketQuery_market;
@ -53,7 +54,10 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => {
null null
); );
const { data, loading, error } = useMarketList(); const { data, loading, error } = useDataProvider({
dataProvider: marketsProvider,
noUpdate: true,
});
const outsideClickCb = useCallback(() => { const outsideClickCb = useCallback(() => {
if (!isMobile) { if (!isMobile) {
@ -240,7 +244,7 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => {
useEffect(() => { useEffect(() => {
setResults( setResults(
data?.markets?.filter( data?.filter(
(item) => (item) =>
item.state === MarketState.STATE_ACTIVE && item.state === MarketState.STATE_ACTIVE &&
item.tradableInstrument.instrument.name.match( item.tradableInstrument.instrument.name.match(