Skip to content

Commit

Permalink
fix: display issue in explorer indexers (#981)
Browse files Browse the repository at this point in the history
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); 
};
```
  • Loading branch information
Kevin101Zhang authored Aug 6, 2024
1 parent a95a48f commit 24eac56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
16 changes: 7 additions & 9 deletions frontend/widgets/src/QueryApi.Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Widget
src={"wendersonpires.near/widget/NearSocialBridgeCore"}
props={props}
props={{
externalAppUrl,
path,
initialViewHeight,
initialPayload,
requestHandler,
}}
/>
);
5 changes: 3 additions & 2 deletions frontend/widgets/src/QueryApi.IndexerExplorer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down

0 comments on commit 24eac56

Please sign in to comment.