Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit 41349ee

Browse files
authored
fix: use null auth store, use hook instead of zust store (#1940)
1 parent 33d6246 commit 41349ee

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎apps/code/src/renderer/features/auth/hooks/authQueries.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
3946
export async function refreshAuthStateQuery(): Promise<void> {
4047
await queryClient.invalidateQueries(trpc.auth.getState.pathFilter());
4148
}

‎apps/code/src/renderer/utils/posthogLinks.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useAuthStore } from "@features/auth/stores/authStore";
1+
import { getCachedAuthState } from "@features/auth/hooks/authQueries";
22
import type { CloudRegion } from "@shared/types/regions";
33
import { getPostHogUrl } from "@utils/urls";
44

@@ -9,7 +9,7 @@ export interface LinkOverrides {
99

1010
function 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

1515
function withProjectId(

‎apps/code/src/renderer/utils/urls.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { useAuthStore } from "@features/auth/stores/authStore";
1+
import { getCachedAuthState } from "@features/auth/hooks/authQueries";
22
import type { CloudRegion } from "@shared/types/regions";
33
import { getCloudUrlFromRegion } from "@shared/utils/urls";
44

55
export 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}`}`;

0 commit comments

Comments
 (0)