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

Function useCheckLocation

packages/shared/src/hooks/useCheckLocation.ts:8–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import { CHECK_LOCATION_QUERY } from '../graphql/users';
7
8export const useCheckLocation = (): void => {
9 const { user, isFetched, updateUser } = useAuthContext();
10 const { requestMethod } = useRequestProtocol();
11
12 useQuery({
13 queryKey: generateQueryKey(RequestKey.CheckLocation, user),
14 queryFn: async () => {
15 const result = await requestMethod<{
16 location: Pick<LoggedUser, 'hasLocationSet'>;
17 }>(CHECK_LOCATION_QUERY);
18 await updateUser({
19 ...user!,
20 hasLocationSet: !!result,
21 });
22 },
23 staleTime: Infinity,
24 gcTime: Infinity,
25 enabled: !!user && isFetched && !user.hasLocationSet,
26 });
27};

Callers 2

InternalAppFunction · 0.90
InternalAppFunction · 0.90

Calls 3

useAuthContextFunction · 0.90
useRequestProtocolFunction · 0.90
generateQueryKeyFunction · 0.90

Tested by

no test coverage detected