This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

semble / src / webapp / features / collections / lib / queries / useCollection.tsx
786 B 29 lines
1import { useSuspenseInfiniteQuery } from '@tanstack/react-query'; 2import { getCollectionPageByAtUri } from '../dal'; 3import { collectionKeys } from '../collectionKeys'; 4 5interface Props { 6 rkey: string; 7 handle: string; 8 limit?: number; 9} 10 11export default function useCollection(props: Props) { 12 const limit = props.limit ?? 20; 13 14 return useSuspenseInfiniteQuery({ 15 queryKey: collectionKeys.infinite(props.rkey), 16 initialPageParam: 1, 17 queryFn: ({ pageParam }) => 18 getCollectionPageByAtUri({ 19 recordKey: props.rkey, 20 handle: props.handle, 21 params: { limit, page: pageParam }, 22 }), 23 getNextPageParam: (lastPage) => { 24 return lastPage.pagination.hasMore 25 ? lastPage.pagination.currentPage + 1 26 : undefined; 27 }, 28 }); 29}