Skip to content

Commit 1720e08

Browse files
committed
fix: Default hasMoreResults to true until data is loaded
The infinite scroll trigger was broken because hasMoreResults returned undefined (falsy) when SWR data hadn't loaded yet. This prevented the InfiniteScroll component from triggering the next fetch. When using SSR initialClimbs, the client-side SWR fetch hasn't completed yet, so hasMoreResults was undefined. Now it defaults to true until we have actual data to determine the correct value.
1 parent 0c88546 commit 1720e08

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/web/app/components/queue-control/hooks/use-queue-data-fetching.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export const useQueueDataFetching = ({
6161
initialSize: searchParams.page ? searchParams.page + 1 : 1,
6262
});
6363

64-
const hasMoreResults = data && data[0] && size * PAGE_LIMIT < data[0].totalCount;
64+
// Default to true until we have data, so infinite scroll works before first fetch completes
65+
const hasMoreResults = data?.[0] ? size * PAGE_LIMIT < data[0].totalCount : true;
6566
const totalSearchResultCount = (data && data[0] && data[0].totalCount) || null;
6667

6768
const climbSearchResults = useMemo(

0 commit comments

Comments
 (0)