Compare commits
2 Commits
7c80643aba
...
17c1700554
Author | SHA1 | Date | |
---|---|---|---|
17c1700554 | |||
9191336722 |
@ -25,8 +25,8 @@ import { NIP05_REGEX } from '../../constants'
|
|||||||
import styles from './styles.module.scss'
|
import styles from './styles.module.scss'
|
||||||
|
|
||||||
import { TimeoutError } from '../../types/errors/TimeoutError'
|
import { TimeoutError } from '../../types/errors/TimeoutError'
|
||||||
const EXTENSION_LOGIN_DELAY_SECONDS = 2
|
const EXTENSION_LOGIN_DELAY_SECONDS = 5
|
||||||
const EXTENSION_LOGIN_TIMEOUT_SECONDS = EXTENSION_LOGIN_DELAY_SECONDS + 10
|
const EXTENSION_LOGIN_TIMEOUT_SECONDS = EXTENSION_LOGIN_DELAY_SECONDS + 55
|
||||||
|
|
||||||
export const Nostr = () => {
|
export const Nostr = () => {
|
||||||
const [searchParams] = useSearchParams()
|
const [searchParams] = useSearchParams()
|
||||||
@ -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)
|
||||||
@ -375,13 +378,21 @@ export const Nostr = () => {
|
|||||||
<LoadingSpinner desc={loadingSpinnerDesc}>
|
<LoadingSpinner desc={loadingSpinnerDesc}>
|
||||||
{isExtensionSlow && (
|
{isExtensionSlow && (
|
||||||
<>
|
<>
|
||||||
<p>Extension is not responding</p>
|
<p>
|
||||||
|
Your nostr extension is not responding. Check these
|
||||||
|
alternatives:{' '}
|
||||||
|
<a href="https://github.com/aljazceru/awesome-nostr?tab=readme-ov-file#nip-07-browser-extensions">
|
||||||
|
https://github.com/aljazceru/awesome-nostr
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<br />
|
||||||
<Button
|
<Button
|
||||||
fullWidth
|
fullWidth
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setLoadingSpinnerDesc('')
|
setLoadingSpinnerDesc('')
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
setIsExtensionSlow(false)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Close
|
Close
|
||||||
|
Loading…
Reference in New Issue
Block a user