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

Function useTopReader

packages/shared/src/hooks/useTopReader.ts:19–41  ·  view source on GitHub ↗
({ limit = 5, user, badgeId })

Source from the content-addressed store, hash-verified

17};
18
19export const useTopReader: UseTopReader = ({ limit = 5, user, badgeId }) => {
20 const { data = [], isPending } = useQuery({
21 queryKey: generateQueryKey(
22 RequestKey.TopReaderBadge,
23 user,
24 badgeId ?? `latest:${limit}`,
25 ),
26 queryFn: async () => {
27 if (badgeId) {
28 return [await fetchTopReaderById(badgeId)];
29 }
30
31 return fetchTopReaders(limit, user.id);
32 },
33 staleTime: StaleTime.OneHour,
34 ...disabledRefetch,
35 });
36
37 return {
38 data,
39 isPending,
40 };
41};

Callers 2

TopReaderBadgeModalFunction · 0.90
BadgesAndAwardsFunction · 0.90

Calls 3

generateQueryKeyFunction · 0.90
fetchTopReaderByIdFunction · 0.90
fetchTopReadersFunction · 0.90

Tested by

no test coverage detected