fix(native): hand a resumed browser sign-in over to the app like every other sign-in

When Android restarted the app during a system browser sign-in, the resumed sign-in waited on the web takeoff timer, so the sign-in screen faded to an empty page and the app rose in without its handover or success tap.
This commit is contained in:
Maurice
2026-11-28 00:30:00 +01:00
parent bbc9c72168
commit 9bfdd10638
2 changed files with 6 additions and 3 deletions
@@ -58,6 +58,7 @@ beforeEach(() => {
vi.mocked(signInThroughBrowser).mockReset();
vi.mocked(resumeBrowserSignIn).mockReset().mockResolvedValue(false);
vi.mocked(startAuthentication).mockReset();
vi.mocked(toastHaptic).mockClear();
loadUser.mockClear();
useAuthStore.setState({ loadUser });
Object.defineProperty(window, 'location', {
@@ -72,6 +73,7 @@ afterEach(() => {
if (realLanguages) Object.defineProperty(window.navigator, 'languages', realLanguages);
else delete (window.navigator as { languages?: readonly string[] }).languages;
localStorage.removeItem('app_language');
document.documentElement.removeAttribute('data-app-handover');
Object.defineProperty(window, 'location', { configurable: true, writable: true, value: realLocation });
});
@@ -186,5 +188,6 @@ describe('useLogin in the native app', () => {
await waitFor(() => expect(result.current.showTakeoff).toBe(true));
expect(toastHaptic).toHaveBeenCalledWith('success');
await waitFor(() => expect(mockNavigate).toHaveBeenCalledWith('/'), { timeout: 2500 });
expect(document.documentElement.hasAttribute('data-app-handover')).toBe(true);
});
});
+3 -3
View File
@@ -351,10 +351,10 @@ export function useLogin() {
if (!signedIn) return
await loadUser({ silent: true })
setShowTakeoff(true)
void loadSettings()
setTimeout(() => {
toastHaptic('success')
void handOverToApp(loadSettings(), () => {
void navigate(redirectTarget)
}, 2600)
})
})
.catch(() => setError(t('native.login.failed')))
}, [nativeApp, loadUser, loadSettings, navigate, redirectTarget, t])