From eb6069098b1a01c4fcd027cee3f5ad929b5daf3f Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 8 Nov 2025 09:26:54 +0000 Subject: [PATCH] Ensure loading is false immediately after signOut, don't rely on callback cgen-ea5718d6e90447a5beaaf996136f5f41 --- client/contexts/AuthContext.tsx | 35 ++++++++++++++------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/client/contexts/AuthContext.tsx b/client/contexts/AuthContext.tsx index 16a78ea9..f443dff0 100644 --- a/client/contexts/AuthContext.tsx +++ b/client/contexts/AuthContext.tsx @@ -819,7 +819,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ }, [clearClientAuthState]); const signOut = async () => { - // Clear local session immediately - don't show loading + // Clear local session immediately try { await supabase.auth.signOut({ scope: "local", @@ -828,33 +828,28 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ console.warn("Local sign-out error:", error); } + // Clear state immediately - this ensures buttons appear right away clearClientAuthState(); + setLoading(false); // Fire and forget global sign-out - don't wait for it, don't block UI supabase.auth .signOut({ scope: "global" }) .catch((error) => { console.warn("Global sign-out error:", error); - // Still try to show a toast even if global fails - try { - aethexToast.info({ - title: "Signed out", - description: "You have been signed out successfully (local only).", - }); - } catch (e) { - /* ignore */ - } - }) - .then(() => { - try { - aethexToast.info({ - title: "Signed out", - description: "You have been signed out successfully.", - }); - } catch (e) { - /* ignore */ - } }); + + // Show toast after UI is updated + setTimeout(() => { + try { + aethexToast.info({ + title: "Signed out", + description: "Come back soon!", + }); + } catch (e) { + /* ignore */ + } + }, 100); }; const updateProfile = async (updates: Partial) => {