diff options
author | dan <dan.abramov@gmail.com> | 2024-08-15 20:58:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-15 20:58:13 +0100 |
commit | b6e515c664d51ffe357c3562fd514301805ade8c (patch) | |
tree | ac0193c172d6c7ef62ac59d411c2dfc7ae1614c3 /src/view/screens/Settings/index.tsx | |
parent | f3b57dd45600c0c8197ce45a0f927b57e0799760 (diff) | |
download | voidsky-b6e515c664d51ffe357c3562fd514301805ade8c.tar.zst |
Move global "Sign out" out of the current account row (#4941)
* Rename logout to logoutEveryAccount * Add logoutCurrentAccount() * Make all "Log out" buttons refer to current account Each of these usages is completely contextual and refers to a specific account. * Add Sign out of all accounts to Settings * Move single account Sign Out below as well * Prompt on account removal * Add Other Accounts header to reduce ambiguity * Spacing fix --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
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} /> |