Close account switcher before logging out (#2148)

* Close account switcher before logging out

* Add comment
zio/stable
Eric Bailey 2023-12-08 13:00:19 -06:00 committed by GitHub
parent 528b4b5017
commit 61fa3d506c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import {Trans, msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useSession, useSessionApi, SessionAccount} from '#/state/session' import {useSession, useSessionApi, SessionAccount} from '#/state/session'
import {useProfileQuery} from '#/state/queries/profile' import {useProfileQuery} from '#/state/queries/profile'
import {useCloseAllActiveElements} from '#/state/util'
export const snapPoints = ['40%', '90%'] export const snapPoints = ['40%', '90%']
@ -32,11 +33,14 @@ function SwitchAccountCard({account}: {account: SessionAccount}) {
const {data: profile} = useProfileQuery({did: account.did}) const {data: profile} = useProfileQuery({did: account.did})
const isCurrentAccount = account.did === currentAccount?.did const isCurrentAccount = account.did === currentAccount?.did
const {onPressSwitchAccount} = useAccountSwitcher() const {onPressSwitchAccount} = useAccountSwitcher()
const closeAllActiveElements = useCloseAllActiveElements()
const onPressSignout = React.useCallback(() => { const onPressSignout = React.useCallback(() => {
track('Settings:SignOutButtonClicked') track('Settings:SignOutButtonClicked')
logout() closeAllActiveElements()
}, [track, logout]) // needs to be in timeout or the modal re-opens
setTimeout(() => logout(), 0)
}, [track, logout, closeAllActiveElements])
const contents = ( const contents = (
<View style={[pal.view, styles.linkCard]}> <View style={[pal.view, styles.linkCard]}>