From 353e5d6374c77a2744590a5bfd3329672009b281 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 22 Dec 2024 16:17:22 +0000 Subject: feat: Add basic pagination to searchBookmarks tRPC --- apps/mobile/app/dashboard/search.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'apps/mobile/app') diff --git a/apps/mobile/app/dashboard/search.tsx b/apps/mobile/app/dashboard/search.tsx index 884345e7..de3d0f46 100644 --- a/apps/mobile/app/dashboard/search.tsx +++ b/apps/mobile/app/dashboard/search.tsx @@ -17,10 +17,15 @@ export default function Search() { const onRefresh = api.useUtils().bookmarks.searchBookmarks.invalidate; - const { data, error, refetch, isPending } = - api.bookmarks.searchBookmarks.useQuery( + const { data, error, refetch, isPending, fetchNextPage, isFetchingNextPage } = + api.bookmarks.searchBookmarks.useInfiniteQuery( { text: query }, - { placeholderData: keepPreviousData }, + { + placeholderData: keepPreviousData, + gcTime: 0, + initialCursor: null, + getNextPageParam: (lastPage) => lastPage.nextCursor, + }, ); if (error) { @@ -45,7 +50,9 @@ export default function Search() { {!data && } {data && ( p.bookmarks)} + fetchNextPage={fetchNextPage} + isFetchingNextPage={isFetchingNextPage} onRefresh={onRefresh} isRefreshing={isPending} /> -- cgit v1.2.3-70-g09d2