diff --git a/src/pages/nostr/index.tsx b/src/pages/nostr/index.tsx index 557d9e3..0467c9b 100644 --- a/src/pages/nostr/index.tsx +++ b/src/pages/nostr/index.tsx @@ -77,11 +77,12 @@ export const Nostr = () => { } const loginWithExtension = async () => { + let waitTimeout: number | undefined try { // Wait EXTENSION_LOGIN_DELAY_SECONDS before showing extension delay message - const waitTimeout = window.setTimeout(() => { + waitTimeout = window.setTimeout(() => { setIsExtensionSlow(true) - }, 2000) + }, EXTENSION_LOGIN_DELAY_SECONDS * 1000) setIsLoading(true) setLoadingSpinnerDesc('Capturing pubkey from nostr extension') @@ -96,7 +97,6 @@ export const Nostr = () => { ]) if (redirectPath) { - window.clearTimeout(waitTimeout) navigateAfterLogin(redirectPath) } } catch (error) { @@ -106,6 +106,9 @@ export const Nostr = () => { toast.error('Error capturing public key from nostr extension: ' + error) } } finally { + // Clear the wait timeout so we don't change the state unnecessarily + window.clearTimeout(waitTimeout) + setIsLoading(false) setLoadingSpinnerDesc('') setIsExtensionSlow(false) @@ -389,6 +392,7 @@ export const Nostr = () => { onClick={() => { setLoadingSpinnerDesc('') setIsLoading(false) + setIsExtensionSlow(false) }} > Close