From 84d1511972f99da0113ea39886cdb594f0b6f39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20G=C5=82ownia?= Date: Mon, 19 Sep 2022 14:12:39 +0200 Subject: [PATCH] chore: use markets only in market selector, change Instrument cache policy --- .../src/integration/market-selector.test.ts | 3 +-- apps/console-lite/src/app/lib/apollo-client.tsx | 3 +++ .../src/components/deal-ticket/market-selector.tsx | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/console-lite-e2e/src/integration/market-selector.test.ts b/apps/console-lite-e2e/src/integration/market-selector.test.ts index 4c23bb237..ff05c8486 100644 --- a/apps/console-lite-e2e/src/integration/market-selector.test.ts +++ b/apps/console-lite-e2e/src/integration/market-selector.test.ts @@ -23,7 +23,6 @@ describe('market selector', () => { aliasQuery(req, 'Markets', generateSimpleMarkets()); aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); - aliasQuery(req, 'Markets', generateSimpleMarkets()); aliasQuery(req, 'DealTicketQuery', generateDealTicket()); aliasQuery(req, 'MarketTags', generateMarketTags()); 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) { cy.visit(`/trading/${markets[0].id}`); connectVegaWallet(); diff --git a/apps/console-lite/src/app/lib/apollo-client.tsx b/apps/console-lite/src/app/lib/apollo-client.tsx index c2f0d09cc..e51f27871 100644 --- a/apps/console-lite/src/app/lib/apollo-client.tsx +++ b/apps/console-lite/src/app/lib/apollo-client.tsx @@ -38,6 +38,9 @@ export function createClient(base?: string) { Node: { keyFields: false, }, + Instrument: { + keyFields: false, + }, }, }); diff --git a/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx b/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx index 76450e7fc..7082ef50d 100644 --- a/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx @@ -20,11 +20,12 @@ import { t, useScreenDimensions, useOutsideClick, + useDataProvider, } from '@vegaprotocol/react-helpers'; import { IconNames } from '@blueprintjs/icons'; import { MarketState } from '@vegaprotocol/types'; import type { Market } from '@vegaprotocol/market-list'; -import { useMarketList } from '@vegaprotocol/market-list'; +import { marketsProvider } from '@vegaprotocol/market-list'; interface Props { market: DealTicketQuery_market; @@ -53,7 +54,10 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => { null ); - const { data, loading, error } = useMarketList(); + const { data, loading, error } = useDataProvider({ + dataProvider: marketsProvider, + noUpdate: true, + }); const outsideClickCb = useCallback(() => { if (!isMobile) { @@ -240,7 +244,7 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => { useEffect(() => { setResults( - data?.markets?.filter( + data?.filter( (item) => item.state === MarketState.STATE_ACTIVE && item.tradableInstrument.instrument.name.match(