This repository has no description
0

Configure Feed

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

semble / src / webapp / features / feeds / lib / queries / useFollowingFeed.tsx
1.3 kB 49 lines
1import { useInfiniteQuery } from '@tanstack/react-query'; 2import { getFollowingFeed } from '../dal'; 3import { feedKeys } from '../feedKeys'; 4import { UrlType, ActivitySource, ActivityType } from '@semble/types'; 5 6interface Props { 7 limit?: number; 8 urlType?: UrlType; 9 source?: ActivitySource; 10 activityTypes?: ActivityType[]; 11 includeKnownBots?: boolean; 12 enabled?: boolean; 13} 14 15export default function useFollowingFeed(props?: Props) { 16 const limit = props?.limit ?? 15; 17 const enabled = props?.enabled ?? true; 18 19 const query = useInfiniteQuery({ 20 queryKey: feedKeys.followingInfinite( 21 limit, 22 props?.urlType, 23 props?.source, 24 props?.activityTypes, 25 props?.includeKnownBots, 26 ), 27 staleTime: 10000, 28 initialPageParam: 1, 29 enabled, 30 queryFn: ({ pageParam = 1 }) => { 31 return getFollowingFeed({ 32 limit, 33 page: pageParam, 34 urlType: props?.urlType, 35 source: props?.source, 36 activityTypes: props?.activityTypes, 37 includeKnownBots: props?.includeKnownBots, 38 }); 39 }, 40 getNextPageParam: (lastPage) => { 41 if (lastPage.pagination.hasMore) { 42 return lastPage.pagination.currentPage + 1; 43 } 44 return undefined; 45 }, 46 }); 47 48 return query; 49}