From 9960a1db570148e1c41fd5d5073711abd9c0cea0 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 25 Oct 2023 12:48:04 +0800 Subject: [PATCH] chore: rename types --- src/contexts/ActiveAccounts/index.tsx | 11 +++++------ src/contexts/ActiveAccounts/types.ts | 7 +++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/contexts/ActiveAccounts/index.tsx b/src/contexts/ActiveAccounts/index.tsx index 53e2c8d4a8..c3f5ff907c 100644 --- a/src/contexts/ActiveAccounts/index.tsx +++ b/src/contexts/ActiveAccounts/index.tsx @@ -44,14 +44,13 @@ export const ActiveAccountsProvider = ({ // Setter for the active account. const setActiveAccount = ( newActiveAccount: MaybeAddress, - local: boolean = true + updateLocalStorage: boolean = true ) => { - if (local) - if (newActiveAccount === null) { + if (updateLocalStorage) + if (newActiveAccount === null) localStorage.removeItem(`${network}_active_account`); - } else { - localStorage.setItem(`${network}_active_account`, newActiveAccount); - } + else localStorage.setItem(`${network}_active_account`, newActiveAccount); + setStateWithRef(newActiveAccount, setActiveAccountState, activeAccountRef); }; diff --git a/src/contexts/ActiveAccounts/types.ts b/src/contexts/ActiveAccounts/types.ts index 19a05d2c72..dc5f98cc2a 100644 --- a/src/contexts/ActiveAccounts/types.ts +++ b/src/contexts/ActiveAccounts/types.ts @@ -8,8 +8,11 @@ export interface ActiveAccountsContextInterface { activeProxy: MaybeAddress; activeProxyType: string | null; getActiveAccount: () => string | null; - setActiveAccount: (address: MaybeAddress, updateLocal?: boolean) => void; - setActiveProxy: (address: ActiveProxy, updateLocal?: boolean) => void; + setActiveAccount: ( + address: MaybeAddress, + updateLocalStorage?: boolean + ) => void; + setActiveProxy: (address: ActiveProxy, updateLocalStorage?: boolean) => void; } export type ActiveProxy = {