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 / useSembleCollectionts.tsx
765 B 28 lines
1import { useSuspenseInfiniteQuery } from '@tanstack/react-query'; 2import { getCollectionsForUrl } from '../dal'; 3import { collectionKeys } from '../collectionKeys'; 4 5interface Props { 6 url: string; 7 limit?: number; 8} 9 10export default function useSembleCollections(props: Props) { 11 const limit = props?.limit ?? 16; 12 13 const collections = useSuspenseInfiniteQuery({ 14 queryKey: collectionKeys.bySembleUrl(props.url), 15 initialPageParam: 1, 16 queryFn: ({ pageParam = 1 }) => { 17 return getCollectionsForUrl(props.url, { page: pageParam, limit }); 18 }, 19 getNextPageParam: (lastPage) => { 20 if (lastPage.pagination.hasMore) { 21 return lastPage.pagination.currentPage + 1; 22 } 23 return undefined; 24 }, 25 }); 26 27 return collections; 28}