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, '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();

View File

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

View File

@ -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(