From 0f671b2eec8924e0e9a0835d8bad01525535697b Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 18 Oct 2025 00:43:43 +0000 Subject: [PATCH] Add auto-resend effect with localStorage guard cgen-8ed044ff2dcf45f39af440d1435c9384 --- client/components/onboarding/Welcome.tsx | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/client/components/onboarding/Welcome.tsx b/client/components/onboarding/Welcome.tsx index e52b7622..66669eeb 100644 --- a/client/components/onboarding/Welcome.tsx +++ b/client/components/onboarding/Welcome.tsx @@ -299,6 +299,32 @@ export default function Welcome({ } }; + const autoResendTriggeredRef = useRef(false); + useEffect(() => { + if (typeof window === "undefined") return; + if (!emailAddress) return; + if (isVerified) return; + if (autoResendTriggeredRef.current) return; + + const key = `auto_resend_v1:${String(emailAddress).toLowerCase()}`; + try { + if (window.localStorage.getItem(key) === "1") return; + autoResendTriggeredRef.current = true; + window.localStorage.setItem(key, "1"); + // Fire-and-forget; handler manages its own toasts/states + handleResendVerification().catch(() => { + /* ignore */ + }); + } catch { + if (!autoResendTriggeredRef.current) { + autoResendTriggeredRef.current = true; + handleResendVerification().catch(() => { + /* ignore */ + }); + } + } + }, [emailAddress, isVerified]); + const VerificationIcon = isVerified ? MailCheck : MailWarning; const verificationBorderClass = isVerified ? "border-emerald-500/40"