fix: abort dangling fetches and handle localStorage exceptions
- useNostr.ts: wrap auto-restore login fetch with AbortController, abort on logout to cancel in-flight request - useWallet.ts: wrap localStorage.setItem/removeItem calls in try/catch for Safari private browsing quota exceptions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
d98b264935
commit
edd08fde59
@@ -16,8 +16,10 @@ function loadStored<T>(key: string): T | null {
|
||||
} catch { return null }
|
||||
}
|
||||
function store(key: string, value: unknown) {
|
||||
if (value == null) localStorage.removeItem(key)
|
||||
else localStorage.setItem(key, JSON.stringify(value))
|
||||
try {
|
||||
if (value == null) localStorage.removeItem(key)
|
||||
else localStorage.setItem(key, JSON.stringify(value))
|
||||
} catch { /* Safari private browsing quota exception */ }
|
||||
}
|
||||
|
||||
const isWalletConnected = ref(!!loadStored<string>('bf_wallet_method'))
|
||||
@@ -73,7 +75,7 @@ export function useWallet() {
|
||||
}
|
||||
|
||||
// Store NWC string locally for client-side payment sending
|
||||
localStorage.setItem('bf_nwc_url', connectionString)
|
||||
try { localStorage.setItem('bf_nwc_url', connectionString) } catch { /* quota */ }
|
||||
walletMethod.value = 'nwc'
|
||||
isWalletConnected.value = true
|
||||
store('bf_wallet_method', 'nwc')
|
||||
@@ -120,7 +122,7 @@ export function useWallet() {
|
||||
paymentStatus.value = 'idle'
|
||||
pendingPayment.value = null
|
||||
store('bf_wallet_method', null)
|
||||
localStorage.removeItem('bf_nwc_url')
|
||||
try { localStorage.removeItem('bf_nwc_url') } catch { /* quota */ }
|
||||
}
|
||||
|
||||
async function checkWalletStatus(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user