Commit 9d5e0701 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

fix: disable polling after scroll (#5191)

disable polling after scroll
parent 66bdfd8a
...@@ -224,10 +224,10 @@ export function useLazyLoadAssetsQuery(params: AssetFetcherParams) { ...@@ -224,10 +224,10 @@ export function useLazyLoadAssetsQuery(params: AssetFetcherParams) {
const POLLING_INTERVAL = ms`5s` const POLLING_INTERVAL = ms`5s`
const environment = useRelayEnvironment() const environment = useRelayEnvironment()
const poll = useCallback(async () => { const poll = useCallback(async () => {
const length = data.nftAssets?.edges?.length if (data.nftAssets?.edges?.length > ASSET_PAGE_SIZE) return
// Initiate a network request. When it resolves, refresh the UI from store (to avoid re-triggering Suspense); // Initiate a network request. When it resolves, refresh the UI from store (to avoid re-triggering Suspense);
// see: https://relay.dev/docs/guided-tour/refetching/refreshing-queries/#if-you-need-to-avoid-suspense-1. // see: https://relay.dev/docs/guided-tour/refetching/refreshing-queries/#if-you-need-to-avoid-suspense-1.
await fetchQuery<AssetQuery>(environment, assetQuery, { ...vars, first: length }).toPromise() await fetchQuery<AssetQuery>(environment, assetQuery, { ...vars }).toPromise()
setFetchKey((fetchKey) => fetchKey + 1) setFetchKey((fetchKey) => fetchKey + 1)
}, [data.nftAssets?.edges?.length, environment, vars]) }, [data.nftAssets?.edges?.length, environment, vars])
useInterval(poll, isLoadingNext ? null : POLLING_INTERVAL, /* leading= */ false) useInterval(poll, isLoadingNext ? null : POLLING_INTERVAL, /* leading= */ false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment