From b7880bbd4d1eab2213a9db2b7f4bb32532d0a638 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Wed, 21 Oct 2026 19:33:28 +0300 Subject: [PATCH] [APP-3590] Fix endless spinner on the signup captcha step when device attestation passes (#12119) --- .../StepCaptcha/CaptchaWebView.shared.ts | 1 - .../Signup/StepCaptcha/CaptchaWebView.tsx | 33 ++++--------------- src/screens/Signup/StepCaptcha/index.tsx | 1 - src/screens/Signup/state.ts | 5 ++- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/src/screens/Signup/StepCaptcha/CaptchaWebView.shared.ts b/src/screens/Signup/StepCaptcha/CaptchaWebView.shared.ts index c46bd31ec..94f4e20b6 100644 --- a/src/screens/Signup/StepCaptcha/CaptchaWebView.shared.ts +++ b/src/screens/Signup/StepCaptcha/CaptchaWebView.shared.ts @@ -16,7 +16,6 @@ export type CaptchaWebViewProps = { url: string stateParam: string state?: SignupState - onComplete: () => void onSuccess: (code: string) => void onError: (error: CaptchaError) => void /** The user is still working on the challenge after a grace period. */ diff --git a/src/screens/Signup/StepCaptcha/CaptchaWebView.tsx b/src/screens/Signup/StepCaptcha/CaptchaWebView.tsx index fe036e8af..4656e7262 100644 --- a/src/screens/Signup/StepCaptcha/CaptchaWebView.tsx +++ b/src/screens/Signup/StepCaptcha/CaptchaWebView.tsx @@ -1,4 +1,4 @@ -import {useEffect, useMemo, useRef} from 'react' +import {useMemo, useRef} from 'react' import {WebView, type WebViewNavigation} from 'react-native-webview' import {type ShouldStartLoadRequest} from 'react-native-webview/lib/WebViewTypes' @@ -15,8 +15,6 @@ const ALLOWED_HOSTS = [ 'api2.hcaptcha.com', ] -const MIN_DELAY = 3_500 - function safeHost(url: string): string { try { return new URL(url).host @@ -29,22 +27,10 @@ export function CaptchaWebView({ url, stateParam, state, - onComplete, onSuccess, onError, onBlockedLoad, }: CaptchaWebViewProps) { - const startedAt = useRef(Date.now()) - const successTo = useRef(undefined) - - useEffect(() => { - return () => { - if (successTo.current) { - clearTimeout(successTo.current) - } - } - }, []) - const redirectHost = useMemo(() => { if (!state?.serviceUrl) return 'bsky.app' @@ -87,18 +73,13 @@ export function CaptchaWebView({ return } - // We want to delay the completion of this screen ever so slightly so that it doesn't appear to be a glitch if it completes too fast + /* + * Report success synchronously. The parent swaps this view for a spinner + * as soon as it hears about it, so anything deferred from in here (e.g. a + * timer) would be torn down with the view before it could fire. + */ wasSuccessful.current = true - onComplete() - const now = Date.now() - const timeTaken = now - startedAt.current - if (timeTaken < MIN_DELAY) { - successTo.current = setTimeout(() => { - onSuccess(code) - }, MIN_DELAY - timeTaken) - } else { - onSuccess(code) - } + onSuccess(code) } return ( diff --git a/src/screens/Signup/StepCaptcha/index.tsx b/src/screens/Signup/StepCaptcha/index.tsx index 43daa8948..7c30b5828 100644 --- a/src/screens/Signup/StepCaptcha/index.tsx +++ b/src/screens/Signup/StepCaptcha/index.tsx @@ -232,7 +232,6 @@ function StepCaptchaInner({ url={url} stateParam={stateParam} state={state} - onComplete={() => setCompleted(true)} onSuccess={onSuccess} onError={onError} onSlow={onSlow} diff --git a/src/screens/Signup/state.ts b/src/screens/Signup/state.ts index b1285a78f..9d0e3c6fb 100644 --- a/src/screens/Signup/state.ts +++ b/src/screens/Signup/state.ts @@ -382,7 +382,10 @@ export function useSubmitSignup() { value: error, field: isHandleError ? 'handle' : undefined, }) - dispatch({type: 'setStep', value: isHandleError ? 2 : 1}) + dispatch({ + type: 'setStep', + value: isHandleError ? SignupStep.HANDLE : SignupStep.INFO, + }) const expected = classifyExpectedSignupError(e) if (expected) { -- knotmirror 0.0.1