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 / useOpenCollectionsWithContributor.tsx
1.1 kB 37 lines
1import { useSuspenseInfiniteQuery } from '@tanstack/react-query'; 2import { getOpenCollectionsWithContributor } from '../dal'; 3import { collectionKeys } from '../collectionKeys'; 4import { CollectionSortField, GetCollectionsResponse } from '@semble/types'; 5 6interface Props { 7 identifier: string; 8 limit?: number; 9 sortBy?: CollectionSortField; 10} 11 12export default function useOpenCollectionsWithContributor(props: Props) { 13 const limit = props?.limit ?? 10; 14 15 return useSuspenseInfiniteQuery<GetCollectionsResponse>({ 16 queryKey: [ 17 ...collectionKeys.all(), 18 'openWithContributor', 19 props.identifier, 20 props.limit, 21 props.sortBy, 22 ], 23 initialPageParam: 1, 24 queryFn: ({ pageParam }) => 25 getOpenCollectionsWithContributor({ 26 identifier: props.identifier, 27 limit, 28 page: pageParam as number, 29 collectionSortBy: props.sortBy, 30 }), 31 getNextPageParam: (lastPage) => { 32 return lastPage.pagination.hasMore 33 ? lastPage.pagination.currentPage + 1 34 : undefined; 35 }, 36 }); 37}