about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2023-12-08 13:00:19 -0600
committerGitHub <noreply@github.com>2023-12-08 13:00:19 -0600
commit61fa3d506cc8a9bf5154d9a2b1038023748af518 (patch)
treeef7db937a6f4520211372e625bcefd02713551e9 /src
parent528b4b5017bb553c40c91443657eb4faf65c80b9 (diff)
downloadvoidsky-61fa3d506cc8a9bf5154d9a2b1038023748af518.tar.zst
Close account switcher before logging out (#2148)
* Close account switcher before logging out

* Add comment
Diffstat (limited to 'src')
-rw-r--r--src/view/com/modals/SwitchAccount.tsx8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/view/com/modals/SwitchAccount.tsx b/src/view/com/modals/SwitchAccount.tsx
index 38e1ce1e0..37691e717 100644
--- a/src/view/com/modals/SwitchAccount.tsx
+++ b/src/view/com/modals/SwitchAccount.tsx
@@ -20,6 +20,7 @@ import {Trans, msg} from '@lingui/macro'
 import {useLingui} from '@lingui/react'
 import {useSession, useSessionApi, SessionAccount} from '#/state/session'
 import {useProfileQuery} from '#/state/queries/profile'
+import {useCloseAllActiveElements} from '#/state/util'
 
 export const snapPoints = ['40%', '90%']
 
@@ -32,11 +33,14 @@ function SwitchAccountCard({account}: {account: SessionAccount}) {
   const {data: profile} = useProfileQuery({did: account.did})
   const isCurrentAccount = account.did === currentAccount?.did
   const {onPressSwitchAccount} = useAccountSwitcher()
+  const closeAllActiveElements = useCloseAllActiveElements()
 
   const onPressSignout = React.useCallback(() => {
     track('Settings:SignOutButtonClicked')
-    logout()
-  }, [track, logout])
+    closeAllActiveElements()
+    // needs to be in timeout or the modal re-opens
+    setTimeout(() => logout(), 0)
+  }, [track, logout, closeAllActiveElements])
 
   const contents = (
     <View style={[pal.view, styles.linkCard]}>