From 24eac568adf4402db042375ae065ef0fc6ab6d11 Mon Sep 17 00:00:00 2001 From: Kevin Zhang <42101107+Kevin101Zhang@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:09:54 -0400 Subject: [PATCH] fix: display issue in explorer indexers (#981) explore seems to be missing a few indexers and the reason was due to pagination starting from 0. so on load it would grab the intial 50 and then onclick for loadmore it would still grab the 0-50 already on display. fix: changes page to intialize to 1. Initial Load (0-49) Indexers Loaded First Click (page = 1): Loads indexers from 50 to 99. Second Click (page = 2): Loads indexers from 100 to 149. ``` const handleLoadMore = () => { const start = page * PAGE_SIZE; // FIRST: 1*50 = 50 -> SECOND: 2*50 = 100 const end = start + PAGE_SIZE; // FIRST: 50+50 = 100 -> SECOND: 100+50 = 150 const newIndexers = indexers.slice(start, end); // FIRST CLICK: 50-99 -> SECOND CLICK: 100-149 setCurrentPageIndexer([...currentPageIndexer, ...newIndexers]); // FIRST: 0-49 + 50-99, SECOND: 0-99 + 100 - 149 setPage(page + 1); }; ``` --- frontend/widgets/src/QueryApi.Editor.jsx | 16 +++++++--------- .../widgets/src/QueryApi.IndexerExplorer.jsx | 5 +++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/frontend/widgets/src/QueryApi.Editor.jsx b/frontend/widgets/src/QueryApi.Editor.jsx index bfffc7b2..4092627d 100644 --- a/frontend/widgets/src/QueryApi.Editor.jsx +++ b/frontend/widgets/src/QueryApi.Editor.jsx @@ -83,18 +83,16 @@ const requestHandler = (request, response) => { } }; -const props = { - externalAppUrl, - path, - initialViewHeight, - initialPayload, - requestHandler, -}; - // NearSocialBridgeCore widget is the core that makes all the "magic" happens return ( ); diff --git a/frontend/widgets/src/QueryApi.IndexerExplorer.jsx b/frontend/widgets/src/QueryApi.IndexerExplorer.jsx index 8456be1c..cc08954d 100644 --- a/frontend/widgets/src/QueryApi.IndexerExplorer.jsx +++ b/frontend/widgets/src/QueryApi.IndexerExplorer.jsx @@ -188,11 +188,12 @@ useEffect(() => { }, [selectedTab, hasMetadataRendered]); const handleLoadMore = () => { - const start = page * PAGE_SIZE; + const nextPage = page + 1; + const start = nextPage * PAGE_SIZE; const end = start + PAGE_SIZE; const newIndexers = indexers.slice(start, end); setCurrentPageIndexer([...currentPageIndexer, ...newIndexers]); - setPage(page + 1); + setPage(nextPage); }; const backupNearRPCRequest = () => {