From 3b2680fc0ef2708f4e7b54ccdeafdf9eb77a9257 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Fri, 31 May 2024 13:29:30 -0300 Subject: [PATCH 1/2] fix: wait 1 second to ensure relay subscription is open --- src/actions/nostr.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/actions/nostr.ts b/src/actions/nostr.ts index 3ef64339d..87d0d86f7 100644 --- a/src/actions/nostr.ts +++ b/src/actions/nostr.ts @@ -17,6 +17,9 @@ function logInNostr(pubkey: string) { const relay = getState().instance.nostr?.relay; + // HACK: waits 1 second to ensure the relay subscription is open + await new Promise((resolve) => setTimeout(resolve, 1000)); + const token = await dispatch(obtainOAuthToken({ grant_type: 'nostr_bunker', pubkey, @@ -47,4 +50,4 @@ function setNostrPubkey(pubkey: string) { }; } -export { logInNostr, nostrExtensionLogIn, setNostrPubkey, NOSTR_PUBKEY_SET }; \ No newline at end of file +export { logInNostr, nostrExtensionLogIn, setNostrPubkey, NOSTR_PUBKEY_SET }; From 3ebde982c08b4cf087a46126ea66e055f6cdc20c Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Fri, 31 May 2024 13:30:06 -0300 Subject: [PATCH 2/2] fix: set pubkey when the signer changes --- src/api/hooks/nostr/useSignerStream.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/hooks/nostr/useSignerStream.ts b/src/api/hooks/nostr/useSignerStream.ts index 00517bd0e..f2b1c096d 100644 --- a/src/api/hooks/nostr/useSignerStream.ts +++ b/src/api/hooks/nostr/useSignerStream.ts @@ -15,7 +15,7 @@ function useSignerStream() { useEffect(() => { if (signer) { - signer.getPublicKey().then(setPubkey).catch(console.warn); + signer.getPublicKey().then((pubkey) => setPubkey(pubkey)).catch(console.warn); } }, [signer]);