Move single account Sign Out below as well

This commit is contained in:
Dan Abramov
2024-08-15 02:26:49 +01:00
parent ba884ce659
commit 16f9939d15
+22 -46
View File
@@ -57,7 +57,6 @@ import {DeactivateAccountDialog} from '#/screens/Settings/components/DeactivateA
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import {useDialogControl} from '#/components/Dialog' import {useDialogControl} from '#/components/Dialog'
import {BirthDateSettingsDialog} from '#/components/dialogs/BirthDateSettings' import {BirthDateSettingsDialog} from '#/components/dialogs/BirthDateSettings'
import {navigate, resetToTab} from '#/Navigation'
import {Email2FAToggle} from './Email2FAToggle' import {Email2FAToggle} from './Email2FAToggle'
import {ExportCarDialog} from './ExportCarDialog' import {ExportCarDialog} from './ExportCarDialog'
@@ -77,7 +76,6 @@ function SettingsAccountCard({
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
const {currentAccount} = useSession() const {currentAccount} = useSession()
const {logoutCurrentAccount} = useSessionApi()
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
@@ -103,31 +101,7 @@ function SettingsAccountCard({
{account.handle} {account.handle}
</Text> </Text>
</View> </View>
<AccountDropdownBtn account={account} />
{isCurrentAccount ? (
<TouchableOpacity
testID="signOutBtn"
onPress={() => {
if (isNative) {
logoutCurrentAccount('Settings')
resetToTab('HomeTab')
} else {
navigate('Home').then(() => {
logoutCurrentAccount('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} />
)}
</View> </View>
) )
@@ -428,26 +402,28 @@ export function SettingsScreen({}: Props) {
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
{accounts.length > 1 && ( <TouchableOpacity
<TouchableOpacity style={[styles.linkCard, pal.view]}
style={[styles.linkCard, pal.view]} onPress={
onPress={ isSwitchingAccounts ? undefined : onPressLogoutEveryAccount
isSwitchingAccounts ? undefined : onPressLogoutEveryAccount }
} accessibilityRole="button"
accessibilityRole="button" accessibilityLabel={_(msg`Sign out of all accounts`)}
accessibilityLabel={_(msg`Sign out of all accounts`)} accessibilityHint={undefined}>
accessibilityHint={undefined}> <View style={[styles.iconContainer, pal.btn]}>
<View style={[styles.iconContainer, pal.btn]}> <FontAwesomeIcon
<FontAwesomeIcon icon="arrow-right-from-bracket"
icon="arrow-right-from-bracket" style={pal.text as FontAwesomeIconStyle}
style={pal.text as FontAwesomeIconStyle} />
/> </View>
</View> <Text type="lg" style={pal.text}>
<Text type="lg" style={pal.text}> {accounts.length > 1 ? (
<Trans>Sign out of all accounts</Trans> <Trans>Sign out of all accounts</Trans>
</Text> ) : (
</TouchableOpacity> <Trans>Sign out</Trans>
)} )}
</Text>
</TouchableOpacity>
</View> </View>
<View style={styles.spacer20} /> <View style={styles.spacer20} />