From 1a4e05e9f99b479c4704b77bbf6c7551b0c0886b Mon Sep 17 00:00:00 2001 From: Hailey Date: Mon, 22 Apr 2024 14:46:05 -0700 Subject: properly close the switch account dialog (#3558) * properly close the switch account dialog * use it for switch account as well * ensure dialog is closed on unmount Revert "properly check if the ref is null" This reverts commit 8f563808a5d39389b0bc47a31e73cd147d1e7e8b. properly check if the ref is null ensure dialog is closed on unmount * Revert "ensure dialog is closed on unmount" This reverts commit a48548fd8ed53ae3eb08a0e05bb89f641c112b95. --- src/lib/hooks/useAccountSwitcher.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/lib/hooks/useAccountSwitcher.ts') diff --git a/src/lib/hooks/useAccountSwitcher.ts b/src/lib/hooks/useAccountSwitcher.ts index eb1685a0a..6a1cea234 100644 --- a/src/lib/hooks/useAccountSwitcher.ts +++ b/src/lib/hooks/useAccountSwitcher.ts @@ -1,17 +1,15 @@ import {useCallback} from 'react' -import {isWeb} from '#/platform/detection' import {useAnalytics} from '#/lib/analytics/analytics' -import {useSessionApi, SessionAccount} from '#/state/session' -import * as Toast from '#/view/com/util/Toast' -import {useCloseAllActiveElements} from '#/state/util' +import {isWeb} from '#/platform/detection' +import {SessionAccount, useSessionApi} from '#/state/session' import {useLoggedOutViewControls} from '#/state/shell/logged-out' +import * as Toast from '#/view/com/util/Toast' import {LogEvents} from '../statsig/statsig' export function useAccountSwitcher() { const {track} = useAnalytics() const {selectAccount, clearCurrentAccount} = useSessionApi() - const closeAllActiveElements = useCloseAllActiveElements() const {requestSwitchToAccount} = useLoggedOutViewControls() const onPressSwitchAccount = useCallback( @@ -23,7 +21,6 @@ export function useAccountSwitcher() { try { if (account.accessJwt) { - closeAllActiveElements() if (isWeb) { // We're switching accounts, which remounts the entire app. // On mobile, this gets us Home, but on the web we also need reset the URL. @@ -37,7 +34,6 @@ export function useAccountSwitcher() { Toast.show(`Signed in as @${account.handle}`) }, 100) } else { - closeAllActiveElements() requestSwitchToAccount({requestedAccount: account.did}) Toast.show( `Please sign in as @${account.handle}`, @@ -49,13 +45,7 @@ export function useAccountSwitcher() { clearCurrentAccount() // back user out to login } }, - [ - track, - clearCurrentAccount, - selectAccount, - closeAllActiveElements, - requestSwitchToAccount, - ], + [track, clearCurrentAccount, selectAccount, requestSwitchToAccount], ) return {onPressSwitchAccount} -- cgit 1.4.1