This repository was archived by the owner on Aug 6, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,13 @@ export async function fetchAuthState(): Promise<AuthState> {
3636 return await trpcClient . auth . getState . query ( ) ;
3737}
3838
39+ export function getCachedAuthState ( ) : AuthState {
40+ return (
41+ queryClient . getQueryData < AuthState > ( trpc . auth . getState . queryKey ( ) ) ??
42+ ANONYMOUS_AUTH_STATE
43+ ) ;
44+ }
45+
3946export async function refreshAuthStateQuery ( ) : Promise < void > {
4047 await queryClient . invalidateQueries ( trpc . auth . getState . pathFilter ( ) ) ;
4148}
Original file line number Diff line number Diff line change 1- import { useAuthStore } from "@features/auth/stores/authStore " ;
1+ import { getCachedAuthState } from "@features/auth/hooks/authQueries " ;
22import type { CloudRegion } from "@shared/types/regions" ;
33import { getPostHogUrl } from "@utils/urls" ;
44
@@ -9,7 +9,7 @@ export interface LinkOverrides {
99
1010function resolveProjectId ( override ?: number | null ) : number | null {
1111 if ( override != null ) return override ;
12- return useAuthStore . getState ( ) . projectId ?? null ;
12+ return getCachedAuthState ( ) . projectId ?? null ;
1313}
1414
1515function withProjectId (
Original file line number Diff line number Diff line change 1- import { useAuthStore } from "@features/auth/stores/authStore " ;
1+ import { getCachedAuthState } from "@features/auth/hooks/authQueries " ;
22import type { CloudRegion } from "@shared/types/regions" ;
33import { getCloudUrlFromRegion } from "@shared/utils/urls" ;
44
55export function getPostHogUrl (
66 path : string ,
77 regionOverride ?: CloudRegion | null ,
88) : string | null {
9- const region = regionOverride ?? useAuthStore . getState ( ) . cloudRegion ;
9+ const region = regionOverride ?? getCachedAuthState ( ) . cloudRegion ;
1010 if ( ! region ) return null ;
1111 const base = getCloudUrlFromRegion ( region ) ;
1212 return `${ base } ${ path . startsWith ( "/" ) ? path : `/${ path } ` } ` ;
You can’t perform that action at this time.
0 commit comments