From 2342ed4cb26f6c1bbcf93f68caaba0bbea903282 Mon Sep 17 00:00:00 2001 From: Sory Kaba <131464999+SoryAK@users.noreply.github.com> Date: Sun, 18 Oct 2026 10:40:43 -0400 Subject: [PATCH] Keep the Gmail on or off switch right after connecting, so the settings screen type-checks again. Co-authored-by: Cursor --- web/src/GmailSettings.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/src/GmailSettings.tsx b/web/src/GmailSettings.tsx index 91ba823..049594f 100644 --- a/web/src/GmailSettings.tsx +++ b/web/src/GmailSettings.tsx @@ -321,19 +321,24 @@ function openSignInWindow(): Window | null { ); } -async function waitForSignIn(): Promise<{ connected: true; email: string } | null> { +type ConnectedGmail = Extract; + +async function waitForSignIn(): Promise { const started = Date.now(); while (Date.now() - started < 120_000) { await new Promise((resolve) => setTimeout(resolve, 1000)); const response = await fetch("/api/sign-in/gmail/ready", { method: "POST" }); if (!response.ok) continue; const body = (await response.json()) as { connected?: boolean; email?: string }; - if (body.connected && body.email) return { connected: true, email: body.email }; + if (!body.connected || !body.email) continue; + const saved = await fetch("/api/gmail"); + const account = saved.ok ? ((await saved.json()) as GmailAccount) : null; + return account?.connected ? account : { connected: true, email: body.email, enabled: true }; } return null; } -async function waitForGmail(): Promise<{ connected: true; email: string } | null> { +async function waitForGmail(): Promise { const started = Date.now(); while (Date.now() - started < 120_000) { await new Promise((resolve) => setTimeout(resolve, 1000));