This repository has no description
1import { useSuspenseInfiniteQuery } from '@tanstack/react-query';
2import { getGemsActivityFeed } from '../dal';
3import { feedKeys } from '../feedKeys';
4import { UrlType } from '@semble/types';
5
6interface Props {
7 limit?: number;
8 urlType?: UrlType;
9}
10
11export default function useGemsFeed(props?: Props) {
12 const limit = props?.limit ?? 15;
13
14 const query = useSuspenseInfiniteQuery({
15 queryKey: feedKeys.gemsInfinite(limit, props?.urlType),
16 staleTime: 10000,
17 initialPageParam: 1,
18 refetchOnWindowFocus: false,
19 queryFn: ({ pageParam = 1 }) => {
20 return getGemsActivityFeed({
21 limit,
22 page: pageParam,
23 urlType: props?.urlType,
24 });
25 },
26 getNextPageParam: (lastPage) => {
27 if (lastPage.pagination.hasMore) {
28 return lastPage.pagination.currentPage + 1;
29 }
30 return undefined;
31 },
32 });
33
34 return query;
35}