From a12bfc573d82b51ce3fc4b64564622f34b72ae57 Mon Sep 17 00:00:00 2001 From: Bojan Mojsilovic Date: Thu, 25 Apr 2024 12:38:15 +0200 Subject: [PATCH] Modify profile loading --- src/contexts/AccountContext.tsx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/contexts/AccountContext.tsx b/src/contexts/AccountContext.tsx index c59bc55..06a614c 100644 --- a/src/contexts/AccountContext.tsx +++ b/src/contexts/AccountContext.tsx @@ -439,6 +439,14 @@ export function AccountProvider(props: { children: JSXElement }) { if (storedKey) { setPublicKey(storedKey); + + // Read profile from storage + const storedUser = getStoredProfile(storedKey); + + if (storedUser) { + // If it exists, set it as active user + updateStore('activeUser', () => ({...storedUser})); + } } if (nostr === undefined) { @@ -477,14 +485,14 @@ export function AccountProvider(props: { children: JSXElement }) { else { if (key !== storedKey) { setPublicKey(key); - } - // Read profile from storage - const storedUser = getStoredProfile(key); + // Read profile from storage + const storedUser = getStoredProfile(key); - if (storedUser) { - // If it exists, set it as active user - updateStore('activeUser', () => ({...storedUser})); + if (storedUser) { + // If it exists, set it as active user + updateStore('activeUser', () => ({...storedUser})); + } } // Fetch it anyway, maybe there is an update