From 9be72b9f40caf6aa8d784f0dd92b4478d1bc80ee Mon Sep 17 00:00:00 2001 From: Sterling Archer Date: Thu, 25 Jun 2026 11:31:44 -0700 Subject: [PATCH] Wait for redirect result before showing auth screen on iOS --- index.html | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 348c8dc..fbc7a56 100644 --- a/index.html +++ b/index.html @@ -731,18 +731,24 @@ function getFriendDisplayName(uid) { let _initializingUser = false; // AUTH +if (isIOS) { + getRedirectResult(auth).then(async (result) => { + if (result?.user) { + _initializingUser = true; + await initUser(result.user); + } + }).catch(e => console.warn('Redirect result:', e.code)); +} + onAuthStateChanged(auth, async (user) => { if (_initializingUser) return; - - if (isIOS) { - try { - const redirectResult = await getRedirectResult(auth); - if (redirectResult?.user) { - _initializingUser = true; - await initUser(redirectResult.user); - return; - } - } catch(e) { console.warn('Redirect result:', e.code); } + if (isIOS && !user) { + setTimeout(() => { + if (_initializingUser) return; + if (isSignInWithEmailLink(auth, window.location.href)) return; + showScreen('auth'); + }, 1500); + return; } if (isSignInWithEmailLink(auth, window.location.href)) {