Fix the pubkey like CHatGPT said

This commit is contained in:
Alex Gleason 2024-05-31 20:04:50 -05:00
parent 376090015e
commit 3adb570b4a
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 11 additions and 2 deletions

View File

@ -14,9 +14,19 @@ function useSignerStream() {
const authStorageKey = `soapbox:nostr:auth:${pubkey}`; const authStorageKey = `soapbox:nostr:auth:${pubkey}`;
useEffect(() => { useEffect(() => {
let isCancelled = false;
if (signer) { if (signer) {
signer.getPublicKey().then((pubkey) => setPubkey(pubkey)).catch(console.warn); signer.getPublicKey().then((newPubkey) => {
if (!isCancelled) {
setPubkey(newPubkey);
}
}).catch(console.warn);
} }
return () => {
isCancelled = true;
};
}, [signer]); }, [signer]);
useEffect(() => { useEffect(() => {
@ -36,7 +46,6 @@ function useSignerStream() {
return () => { return () => {
connect.close(); connect.close();
}; };
}, [relay, signer, pubkey]); }, [relay, signer, pubkey]);
} }