From f07a40392edaf1a114a3c1860da1b0f835270e9f Mon Sep 17 00:00:00 2001 From: Hugues Chocart Date: Fri, 14 Feb 2025 20:10:14 +0000 Subject: [PATCH] fix: load more (#769) --- packages/frontend/utils/dataHooks/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/frontend/utils/dataHooks/index.ts b/packages/frontend/utils/dataHooks/index.ts index 566298cf..978557a3 100644 --- a/packages/frontend/utils/dataHooks/index.ts +++ b/packages/frontend/utils/dataHooks/index.ts @@ -76,12 +76,10 @@ export function useProjectInfiniteSWR(key: string, ...args: any[]) { const { data, isLoading, isValidating, size, setSize, mutate } = useSWRInfinite(getKey, ...(args as [any])); - const total = data?.[0]?.total; const items = data?.map((d) => d?.data).flat(); + const hasMore = items && items.length === PAGE_SIZE * size; function loadMore() { - const hasMore = items && items?.length < total; - if (hasMore) { setSize((size) => size + 1); } @@ -89,7 +87,6 @@ export function useProjectInfiniteSWR(key: string, ...args: any[]) { return { data: items, - total, isLoading, isValidating, loadMore,