Skip to content

Commit 184d277

Browse files
committed
Disables buttons while seamlessly signing in
1 parent a67883e commit 184d277

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

example/src/screens/Onramp/CryptoOnrampFlow.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export default function CryptoOnrampFlow() {
8383
token: string;
8484
} | null>(null);
8585
const [hasSeamlessSignIn, setHasSeamlessSignIn] = useState(false);
86+
const [isSeamlessSigningIn, setIsSeamlessSigningIn] = useState(false);
8687

8788
const [response, setResponse] = useState<string | null>(null);
8889
const [isLinkUser, setIsLinkUser] = useState(false);
@@ -604,6 +605,7 @@ export default function CryptoOnrampFlow() {
604605

605606
const handleSeamlessSignIn = useCallback(async () => {
606607
if (!storedDemoAuth) return;
608+
setIsSeamlessSigningIn(true);
607609
try {
608610
const latRes = await createLinkAuthToken(storedDemoAuth.token);
609611
if (!latRes.success) {
@@ -649,6 +651,8 @@ export default function CryptoOnrampFlow() {
649651
'Seamless Sign-In Unavailable',
650652
`Please sign in manually. ${e?.message ?? ''}`
651653
);
654+
} finally {
655+
setIsSeamlessSigningIn(false);
652656
}
653657
}, [storedDemoAuth, authenticateUserWithToken, clearPersistedDemoAuth]);
654658

@@ -663,14 +667,18 @@ export default function CryptoOnrampFlow() {
663667
<Text style={styles.boldText}>{storedDemoAuth.email}</Text>.
664668
</Text>
665669
<Button
666-
title="Seamless Sign-In"
670+
title={
671+
isSeamlessSigningIn ? 'Signing In...' : 'Seamless Sign-In'
672+
}
667673
onPress={handleSeamlessSignIn}
668674
variant="primary"
675+
disabled={isSeamlessSigningIn}
669676
/>
670677
<Button
671678
title="Manual Sign-In"
672679
onPress={clearPersistedDemoAuth}
673680
variant="primary"
681+
disabled={isSeamlessSigningIn}
674682
/>
675683
</>
676684
) : (

0 commit comments

Comments
 (0)