From 7ed9d06b8de0332e04ea66c6352e3e0aa728732c Mon Sep 17 00:00:00 2001 From: codytseng Date: Sun, 12 Jan 2025 20:52:56 +0800 Subject: [PATCH] fix: attempt to resolve login bugs --- src/providers/NostrProvider/index.tsx | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/providers/NostrProvider/index.tsx b/src/providers/NostrProvider/index.tsx index 90cb9e59..9226c730 100644 --- a/src/providers/NostrProvider/index.tsx +++ b/src/providers/NostrProvider/index.tsx @@ -55,18 +55,9 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { const act = storage.getCurrentAccount() ?? accounts[0] // auto login the first account if (!act) return - setAccount({ pubkey: act.pubkey, signerType: act.signerType }) - - const pubkey = await loginWithAccountPointer(act) - // login failed, set account to null - if (!pubkey) { - setAccount(null) - return - } + await loginWithAccountPointer(act) } - init().catch(() => { - setAccount(null) - }) + init() }, []) const login = (signer: ISigner, act: TAccount) => { @@ -89,6 +80,7 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { if (!act) { storage.switchAccount(null) setAccount(null) + setSigner(null) return } await loginWithAccountPointer(act) @@ -153,16 +145,6 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { } } else if (account.signerType === 'nip-07') { const nip07Signer = new Nip07Signer() - const pubkey = await nip07Signer.getPublicKey() - if (!pubkey) { - storage.removeAccount(account) - return null - } - if (pubkey !== account.pubkey) { - storage.removeAccount(account) - account = { ...account, pubkey } - storage.addAccount(account) - } return login(nip07Signer, account) } else if (account.signerType === 'bunker') { if (account.bunker && account.bunkerClientSecretKey) {