fix(trading): flickering of market loading (#5006)
This commit is contained in:
parent
66ebb26b0f
commit
b33cf04e16
@ -3,7 +3,7 @@ import { addDecimalsFormatNumber, titlefy } from '@vegaprotocol/utils';
|
|||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import { useScreenDimensions } from '@vegaprotocol/react-helpers';
|
import { useScreenDimensions } from '@vegaprotocol/react-helpers';
|
||||||
import { useThrottledDataProvider } from '@vegaprotocol/data-provider';
|
import { useThrottledDataProvider } from '@vegaprotocol/data-provider';
|
||||||
import { AsyncRenderer, ExternalLink, Splash } from '@vegaprotocol/ui-toolkit';
|
import { ExternalLink, Loader, Splash } from '@vegaprotocol/ui-toolkit';
|
||||||
import { getAsset, marketDataProvider, useMarket } from '@vegaprotocol/markets';
|
import { getAsset, marketDataProvider, useMarket } from '@vegaprotocol/markets';
|
||||||
import { useGlobalStore, usePageTitleStore } from '../../stores';
|
import { useGlobalStore, usePageTitleStore } from '../../stores';
|
||||||
import { TradeGrid } from './trade-grid';
|
import { TradeGrid } from './trade-grid';
|
||||||
@ -68,7 +68,7 @@ export const MarketPage = ({ closed }: { closed?: boolean }) => {
|
|||||||
const update = useGlobalStore((store) => store.update);
|
const update = useGlobalStore((store) => store.update);
|
||||||
const lastMarketId = useGlobalStore((store) => store.marketId);
|
const lastMarketId = useGlobalStore((store) => store.marketId);
|
||||||
|
|
||||||
const { data, error, loading } = useMarket(marketId);
|
const { data, loading } = useMarket(marketId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
@ -110,7 +110,15 @@ export const MarketPage = ({ closed }: { closed?: boolean }) => {
|
|||||||
}
|
}
|
||||||
}, [largeScreen, data, pinnedAsset]);
|
}, [largeScreen, data, pinnedAsset]);
|
||||||
|
|
||||||
if (!data && marketId) {
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<Splash>
|
||||||
|
<Loader />
|
||||||
|
</Splash>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
return (
|
return (
|
||||||
<Splash>
|
<Splash>
|
||||||
<span className="flex flex-col items-center gap-2">
|
<span className="flex flex-col items-center gap-2">
|
||||||
@ -120,7 +128,7 @@ export const MarketPage = ({ closed }: { closed?: boolean }) => {
|
|||||||
<p className="justify-center text-sm">
|
<p className="justify-center text-sm">
|
||||||
{t(`Please choose another market from the`)}{' '}
|
{t(`Please choose another market from the`)}{' '}
|
||||||
<ExternalLink onClick={() => navigate(Links.MARKETS())}>
|
<ExternalLink onClick={() => navigate(Links.MARKETS())}>
|
||||||
market list
|
{t('market list')}
|
||||||
</ExternalLink>
|
</ExternalLink>
|
||||||
</p>
|
</p>
|
||||||
</span>
|
</span>
|
||||||
@ -129,18 +137,13 @@ export const MarketPage = ({ closed }: { closed?: boolean }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsyncRenderer
|
<>
|
||||||
loading={loading}
|
|
||||||
error={error}
|
|
||||||
data={data || undefined}
|
|
||||||
noDataCondition={(data) => false}
|
|
||||||
>
|
|
||||||
<TitleUpdater
|
<TitleUpdater
|
||||||
marketId={data?.id}
|
marketId={data?.id}
|
||||||
marketName={data?.tradableInstrument.instrument.name}
|
marketName={data?.tradableInstrument.instrument.name}
|
||||||
decimalPlaces={data?.decimalPlaces}
|
decimalPlaces={data?.decimalPlaces}
|
||||||
/>
|
/>
|
||||||
{tradeView}
|
{tradeView}
|
||||||
</AsyncRenderer>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user