From f9aa5cbaee7597bf7945f6e9858c7edcc9d664c8 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Tue, 21 Apr 2026 22:54:02 +0200 Subject: [PATCH] fix: skip checkAuth on route change when already authenticated --- app/[locale]/calendar/page.tsx | 9 ++++++++- app/[locale]/contacts/page.tsx | 9 ++++++++- app/[locale]/files/page.tsx | 9 ++++++++- app/[locale]/page.tsx | 9 ++++++++- app/[locale]/settings/page.tsx | 8 ++++++++ 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/app/[locale]/calendar/page.tsx b/app/[locale]/calendar/page.tsx index 9d867766..50069e64 100644 --- a/app/[locale]/calendar/page.tsx +++ b/app/[locale]/calendar/page.tsx @@ -126,8 +126,15 @@ export default function CalendarPage() { } }, [events, detailEvent]); - // Check auth on mount + // Check auth on mount — skip when already authenticated so that navigating + // between routes doesn't retrigger checkAuth's transient `{ client: null, + // isLoading: true }` reset, which was flashing the spinner on every nav. useEffect(() => { + const state = useAuthStore.getState(); + if (state.isAuthenticated && state.client) { + setInitialCheckDone(true); + return; + } checkAuth().finally(() => { setInitialCheckDone(true); }); diff --git a/app/[locale]/contacts/page.tsx b/app/[locale]/contacts/page.tsx index 0b2cd344..b6a1c87d 100644 --- a/app/[locale]/contacts/page.tsx +++ b/app/[locale]/contacts/page.tsx @@ -103,8 +103,15 @@ export default function ContactsPage() { const [isListResizing, setIsListResizing] = useState(false); const listDragStartWidth = useRef(384); - // Check auth on mount + // Check auth on mount — skip when already authenticated so that navigating + // between routes doesn't retrigger checkAuth's transient `{ client: null, + // isLoading: true }` reset, which was flashing the spinner on every nav. useEffect(() => { + const state = useAuthStore.getState(); + if (state.isAuthenticated && state.client) { + setInitialCheckDone(true); + return; + } checkAuth().finally(() => { setInitialCheckDone(true); }); diff --git a/app/[locale]/files/page.tsx b/app/[locale]/files/page.tsx index 0d4c80bc..6725d337 100644 --- a/app/[locale]/files/page.tsx +++ b/app/[locale]/files/page.tsx @@ -105,8 +105,15 @@ export default function FilesPage() { const detailResource = detailName ? resources.find(r => r.name === detailName) || null : null; - // Check auth on mount + // Check auth on mount — skip when already authenticated so that navigating + // between routes doesn't retrigger checkAuth's transient `{ client: null, + // isLoading: true }` reset, which was flashing the spinner on every nav. useEffect(() => { + const state = useAuthStore.getState(); + if (state.isAuthenticated && state.client) { + setInitialCheckDone(true); + return; + } checkAuth().finally(() => { setInitialCheckDone(true); }); diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 3fc1c43f..a72a5638 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -455,8 +455,15 @@ export default function Home() { document.title = title; }, [showComposer, composerMode, selectedEmail, selectedMailbox, mailboxes, t, appName]); - // Check auth on mount + // Check auth on mount — skip when already authenticated so that navigating + // between routes doesn't retrigger checkAuth's transient `{ client: null, + // isLoading: true }` reset, which was flashing the spinner on every nav. useEffect(() => { + const state = useAuthStore.getState(); + if (state.isAuthenticated && state.client) { + setInitialCheckDone(true); + return; + } checkAuth().finally(() => { setInitialCheckDone(true); }); diff --git a/app/[locale]/settings/page.tsx b/app/[locale]/settings/page.tsx index 02b9e1b3..34128ea2 100644 --- a/app/[locale]/settings/page.tsx +++ b/app/[locale]/settings/page.tsx @@ -179,7 +179,15 @@ export default function SettingsPage() { const [isResizing, setIsResizing] = useState(false); const dragStartWidth = useRef(256); + // Check auth on mount — skip when already authenticated so that navigating + // between routes doesn't retrigger checkAuth's transient `{ client: null, + // isLoading: true }` reset, which was flashing the spinner on every nav. useEffect(() => { + const state = useAuthStore.getState(); + if (state.isAuthenticated && state.client) { + setInitialCheckDone(true); + return; + } checkAuth().finally(() => { setInitialCheckDone(true); });