From 75b6f07136c55c827ea4e07b043c0e46dcd06504 Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Mon, 27 Mar 2023 19:40:16 +0800 Subject: [PATCH] Load orgs after profile endpoint in auth provider --- studio/lib/auth.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/studio/lib/auth.tsx b/studio/lib/auth.tsx index 902be2efd73..29e1f6181d0 100644 --- a/studio/lib/auth.tsx +++ b/studio/lib/auth.tsx @@ -58,7 +58,7 @@ export const AuthContext = createContext({ export type AuthProviderProps = {} export const AuthProvider = ({ children }: PropsWithChildren) => { - const { ui } = useStore() + const { ui, app } = useStore() const [session, setSession] = useState(null) const [isLoading, setIsLoading] = useState(true) @@ -121,6 +121,12 @@ export const AuthProvider = ({ children }: PropsWithChildren) useProfileQuery({ onSuccess(profile) { ui.setProfile(profile) + + // [Joshen] Temp fix: For new users, the GET profile call also creates a default org + // But because the dashboard's logged in state is using gotrue as the source of truth + // the home page loads before the GET profile call completes (and consequently before the + // creation of the default org). Hence why calling org load here + app.organizations.load() }, // Never rerun the query staleTime: Infinity,