From bfe196bac5e618bfbeab4f6fabef3e5a18194868 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 7 Nov 2023 13:37:47 -0600 Subject: Extract shell state into separate context (#1824) * WIP * Add shell state * Integrate new shell state for drawer and minimal shell mode * Replace isDrawerSwipeDisabled * Split shell state into separate contexts to avoid needless re-renders * Fix typo --------- Co-authored-by: Paul Frazee --- src/lib/hooks/useAccountSwitcher.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/lib/hooks/useAccountSwitcher.ts') diff --git a/src/lib/hooks/useAccountSwitcher.ts b/src/lib/hooks/useAccountSwitcher.ts index 85bd5d0d4..1ddb181a8 100644 --- a/src/lib/hooks/useAccountSwitcher.ts +++ b/src/lib/hooks/useAccountSwitcher.ts @@ -6,6 +6,7 @@ import {NavigationProp} from 'lib/routes/types' import {AccountData} from 'state/models/session' import {reset as resetNavigation} from '../../Navigation' import * as Toast from 'view/com/util/Toast' +import {useSetDrawerOpen} from '#/state/shell/drawer-open' export function useAccountSwitcher(): [ boolean, @@ -13,8 +14,8 @@ export function useAccountSwitcher(): [ (acct: AccountData) => Promise, ] { const {track} = useAnalytics() - const store = useStores() + const setDrawerOpen = useSetDrawerOpen() const [isSwitching, setIsSwitching] = useState(false) const navigation = useNavigation() @@ -23,6 +24,7 @@ export function useAccountSwitcher(): [ track('Settings:SwitchAccountButtonClicked') setIsSwitching(true) const success = await store.session.resumeSession(acct) + setDrawerOpen(false) store.shell.closeAllActiveElements() if (success) { resetNavigation() @@ -34,7 +36,7 @@ export function useAccountSwitcher(): [ store.session.clear() } }, - [track, setIsSwitching, navigation, store], + [track, setIsSwitching, navigation, store, setDrawerOpen], ) return [isSwitching, setIsSwitching, onPressSwitchAccount] -- cgit 1.4.1