From daee54729b26e51266939a75dfc2783a345b54a1 Mon Sep 17 00:00:00 2001 From: Bran <52735957+brancoder@users.noreply.github.com> Date: Thu, 26 Dec 2024 18:24:03 +0100 Subject: [PATCH] fix(wallet): improve fetching visual assets on higher numbered pages (#4591) --- apps/wallet/src/ui/app/pages/home/nfts/index.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/wallet/src/ui/app/pages/home/nfts/index.tsx b/apps/wallet/src/ui/app/pages/home/nfts/index.tsx index 52c62bf96ae..2b2cbae89d8 100644 --- a/apps/wallet/src/ui/app/pages/home/nfts/index.tsx +++ b/apps/wallet/src/ui/app/pages/home/nfts/index.tsx @@ -127,6 +127,20 @@ function NftsPage() { } }, [ownedAssets]); + useEffect(() => { + // Fetch the next page if there are no visual assets, other + hidden assets are present in multiples of 50, and there are more pages to fetch + if ( + hasNextPage && + ownedAssets?.visual.length === 0 && + ownedAssets?.other.length + ownedAssets?.hidden.length > 0 && + (ownedAssets.other.length + ownedAssets.hidden.length) % 50 === 0 && + !isFetchingNextPage + ) { + fetchNextPage(); + setSelectedAssetCategory(null); + } + }, [hasNextPage, ownedAssets, isFetchingNextPage]); + if (isLoading) { return (