Extension login infinite loading #198

Merged
enes merged 13 commits from 196-ext-login-infinite-loading into staging 2024-09-16 12:27:44 +00:00
Showing only changes of commit 17c1700554 - Show all commits

View File

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