MCPcopy Create free account
hub / github.com/dailydotdev/apps / useSources

Function useSources

packages/shared/src/hooks/source/useSources.ts:50–86  ·  view source on GitHub ↗
({
  query = {},
  isEnabled = true,
}: UseSourcesProps = {})

Source from the content-addressed store, hash-verified

48}
49
50export const useSources = <T extends Source | Squad>({
51 query = {},
52 isEnabled = true,
53}: UseSourcesProps = {}): UseSources<T> => {
54 const {
55 featured,
56 isPublic,
57 categoryId,
58 first = 100,
59 sortByMembersCount,
60 } = query;
61 const result = useInfiniteQuery({
62 queryKey: generateQueryKey(
63 RequestKey.Sources,
64 undefined,
65 featured,
66 isPublic,
67 categoryId,
68 first,
69 ),
70 queryFn: ({ pageParam }) =>
71 gqlClient.request(SOURCES_QUERY, {
72 filterOpenSquads: isPublic,
73 categoryId,
74 featured,
75 first,
76 after: pageParam,
77 sortByMembersCount,
78 }),
79 initialPageParam: '',
80 getNextPageParam: ({ sources }) => getNextPageParam(sources?.pageInfo),
81 staleTime: StaleTime.Default,
82 enabled: isEnabled,
83 });
84
85 return { result };
86};

Callers 4

SquadsDirectoryFeedFunction · 0.90
SquadsPageFunction · 0.90
SquadCategoryPageFunction · 0.90

Calls 2

generateQueryKeyFunction · 0.90
getNextPageParamFunction · 0.90

Tested by

no test coverage detected