Fetch nostr key when not in root

This commit is contained in:
Bojan Mojsilovic 2024-02-26 14:52:05 +01:00
parent 5b9e4ca2ea
commit 0e586d6631
2 changed files with 15 additions and 7 deletions

View File

@ -78,6 +78,14 @@ const Layout: Component = () => {
}
}
createEffect(() => {
if (location.pathname === '/' || account?.isKeyLookupDone) return;
setTimeout(() => {
account?.actions.checkNostrKey();
}, 1000);
});
return (
<Show
when={location.pathname !== '/'}

View File

@ -90,6 +90,7 @@ export type AccountContextStore = {
logout: () => 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<AccountContextStore>({
logout,
showGetStarted,
saveEmoji,
checkNostrKey,
},
});