File tree 2 files changed +9
-16
lines changed
2 files changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,11 @@ import {
5
5
GetUsersResponse ,
6
6
UpdateUserPasswordRequest ,
7
7
UpdateUserProfileRequest ,
8
- User ,
9
8
UsersRequest ,
9
+ User ,
10
10
} from "api/typesGenerated" ;
11
- import { getMetadataAsJSON } from "utils/metadata" ;
12
11
import { getAuthorizationKey } from "./authCheck" ;
12
+ import { getMetadataAsJSON } from "utils/metadata" ;
13
13
14
14
export const users = ( req : UsersRequest ) : UseQueryOptions < GetUsersResponse > => {
15
15
return {
@@ -89,21 +89,14 @@ export const authMethods = () => {
89
89
} ;
90
90
} ;
91
91
92
- const initialMeData = getMetadataAsJSON < User > ( "user" ) ;
93
- const meKey = [ "me" ] as const ;
92
+ const initialUserData = getMetadataAsJSON < User > ( "user" ) ;
94
93
95
- export const me = ( queryClient : QueryClient ) => {
94
+ export const me = ( ) => {
96
95
return {
97
- queryKey : meKey ,
98
- queryFn : async ( ) => {
99
- const cachedData = queryClient . getQueryData ( meKey ) ;
100
- if ( cachedData === undefined && initialMeData !== undefined ) {
101
- return initialMeData ;
102
- }
103
-
104
- return API . getAuthenticatedUser ( ) ;
105
- } ,
106
- } satisfies UseQueryOptions < User > ;
96
+ queryKey : [ "me" ] ,
97
+ initialData : initialUserData ,
98
+ queryFn : API . getAuthenticatedUser ,
99
+ } ;
107
100
} ;
108
101
109
102
export const hasFirstUser = ( ) => {
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ const AuthContext = createContext<AuthContextValue | undefined>(undefined);
46
46
47
47
export const AuthProvider : FC < PropsWithChildren > = ( { children } ) => {
48
48
const queryClient = useQueryClient ( ) ;
49
- const meOptions = me ( queryClient ) ;
49
+ const meOptions = me ( ) ;
50
50
51
51
const userQuery = useQuery ( meOptions ) ;
52
52
const authMethodsQuery = useQuery ( authMethods ( ) ) ;
You can’t perform that action at this time.
0 commit comments