From 0e586d66319b0fba4354e7e5a87c35f4716d18d4 Mon Sep 17 00:00:00 2001 From: Bojan Mojsilovic Date: Mon, 26 Feb 2024 14:52:05 +0100 Subject: [PATCH] Fetch nostr key when not in root --- src/components/Layout/Layout.tsx | 8 ++++++++ src/contexts/AccountContext.tsx | 14 +++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/Layout/Layout.tsx b/src/components/Layout/Layout.tsx index 9f0dd80..a31e056 100644 --- a/src/components/Layout/Layout.tsx +++ b/src/components/Layout/Layout.tsx @@ -78,6 +78,14 @@ const Layout: Component = () => { } } + createEffect(() => { + if (location.pathname === '/' || account?.isKeyLookupDone) return; + + setTimeout(() => { + account?.actions.checkNostrKey(); + }, 1000); + }); + return ( void, showGetStarted: () => void, saveEmoji: (emoji: EmojiOption) => void, + checkNostrKey: () => void, }, } @@ -1105,14 +1106,12 @@ export function AccountProvider(props: { children: JSXElement }) { saveEmojiHistory(store.publicKey, store.emojiHistory); }; -// EFFECTS -------------------------------------- + const checkNostrKey = () => { + updateStore('isKeyLookupDone', false); + fetchNostrKey(); + }; - onMount(() => { - setTimeout(() => { - updateStore('isKeyLookupDone', false); - fetchNostrKey(); - }, 1000); - }); +// EFFECTS -------------------------------------- createEffect(() => { const pubkey = store.publicKey; @@ -1325,6 +1324,7 @@ const [store, updateStore] = createStore({ logout, showGetStarted, saveEmoji, + checkNostrKey, }, });