diff options
Diffstat (limited to 'src/view/screens/Settings/index.tsx')
-rw-r--r-- | src/view/screens/Settings/index.tsx | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/src/view/screens/Settings/index.tsx b/src/view/screens/Settings/index.tsx index 521c2019a..fe449fcdb 100644 --- a/src/view/screens/Settings/index.tsx +++ b/src/view/screens/Settings/index.tsx @@ -57,7 +57,6 @@ import {DeactivateAccountDialog} from '#/screens/Settings/components/DeactivateA import {atoms as a, useTheme} from '#/alf' import {useDialogControl} from '#/components/Dialog' import {BirthDateSettingsDialog} from '#/components/dialogs/BirthDateSettings' -import {navigate, resetToTab} from '#/Navigation' import {Email2FAToggle} from './Email2FAToggle' import {ExportCarDialog} from './ExportCarDialog' @@ -77,7 +76,6 @@ function SettingsAccountCard({ const {_} = useLingui() const t = useTheme() const {currentAccount} = useSession() - const {logout} = useSessionApi() const {data: profile} = useProfileQuery({did: account.did}) const isCurrentAccount = account.did === currentAccount?.did @@ -103,31 +101,7 @@ function SettingsAccountCard({ {account.handle} </Text> </View> - - {isCurrentAccount ? ( - <TouchableOpacity - testID="signOutBtn" - onPress={() => { - if (isNative) { - logout('Settings') - resetToTab('HomeTab') - } else { - navigate('Home').then(() => { - logout('Settings') - }) - } - }} - accessibilityRole="button" - accessibilityLabel={_(msg`Sign out`)} - accessibilityHint={`Signs ${profile?.displayName} out of Bluesky`} - activeOpacity={0.8}> - <Text type="lg" style={pal.link}> - <Trans>Sign out</Trans> - </Text> - </TouchableOpacity> - ) : ( - <AccountDropdownBtn account={account} /> - )} + <AccountDropdownBtn account={account} /> </View> ) @@ -173,6 +147,7 @@ export function SettingsScreen({}: Props) { const {accounts, currentAccount} = useSession() const {mutate: clearPreferences} = useClearPreferencesMutation() const {setShowLoggedOut} = useLoggedOutViewControls() + const {logoutEveryAccount} = useSessionApi() const closeAllActiveElements = useCloseAllActiveElements() const exportCarControl = useDialogControl() const birthdayControl = useDialogControl() @@ -237,6 +212,10 @@ export function SettingsScreen({}: Props) { openModal({name: 'delete-account'}) }, [openModal]) + const onPressLogoutEveryAccount = React.useCallback(() => { + logoutEveryAccount('Settings') + }, [logoutEveryAccount]) + const onPressResetPreferences = React.useCallback(async () => { clearPreferences() }, [clearPreferences]) @@ -394,6 +373,15 @@ export function SettingsScreen({}: Props) { ) : null} <View pointerEvents={pendingDid ? 'none' : 'auto'}> + {accounts.length > 1 && ( + <View style={[s.flexRow, styles.heading, a.mt_sm]}> + <Text type="xl-bold" style={pal.text} numberOfLines={1}> + <Trans>Other accounts</Trans> + </Text> + <View style={s.flex1} /> + </View> + )} + {accounts .filter(a => a.did !== currentAccount?.did) .map(account => ( @@ -422,6 +410,29 @@ export function SettingsScreen({}: Props) { <Trans>Add account</Trans> </Text> </TouchableOpacity> + + <TouchableOpacity + style={[styles.linkCard, pal.view]} + onPress={ + isSwitchingAccounts ? undefined : onPressLogoutEveryAccount + } + accessibilityRole="button" + accessibilityLabel={_(msg`Sign out of all accounts`)} + accessibilityHint={undefined}> + <View style={[styles.iconContainer, pal.btn]}> + <FontAwesomeIcon + icon="arrow-right-from-bracket" + style={pal.text as FontAwesomeIconStyle} + /> + </View> + <Text type="lg" style={pal.text}> + {accounts.length > 1 ? ( + <Trans>Sign out of all accounts</Trans> + ) : ( + <Trans>Sign out</Trans> + )} + </Text> + </TouchableOpacity> </View> <View style={styles.spacer20} /> |