Make all "Log out" buttons refer to current account

Each of these usages is completely contextual and refers to a specific account.
This commit is contained in:
Dan Abramov
2024-08-15 01:34:18 +01:00
parent 10a6a5fd24
commit 02ab29362a
4 changed files with 12 additions and 12 deletions
+3 -3
View File
@@ -38,7 +38,7 @@ export function Deactivated() {
const {setShowLoggedOut} = useLoggedOutViewControls() const {setShowLoggedOut} = useLoggedOutViewControls()
const hasOtherAccounts = accounts.length > 1 const hasOtherAccounts = accounts.length > 1
const setMinimalShellMode = useSetMinimalShellMode() const setMinimalShellMode = useSetMinimalShellMode()
const {logoutEveryAccount} = useSessionApi() const {logoutCurrentAccount} = useSessionApi()
const agent = useAgent() const agent = useAgent()
const [pending, setPending] = React.useState(false) const [pending, setPending] = React.useState(false)
const [error, setError] = React.useState<string | undefined>() const [error, setError] = React.useState<string | undefined>()
@@ -72,8 +72,8 @@ export function Deactivated() {
// So we change the URL ourselves. The navigator will pick it up on remount. // So we change the URL ourselves. The navigator will pick it up on remount.
history.pushState(null, '', '/') history.pushState(null, '', '/')
} }
logoutEveryAccount('Deactivated') logoutCurrentAccount('Deactivated')
}, [logoutEveryAccount]) }, [logoutCurrentAccount])
const handleActivate = React.useCallback(async () => { const handleActivate = React.useCallback(async () => {
try { try {
@@ -35,7 +35,7 @@ function DeactivateAccountDialogInner({
const {gtMobile} = useBreakpoints() const {gtMobile} = useBreakpoints()
const {_} = useLingui() const {_} = useLingui()
const agent = useAgent() const agent = useAgent()
const {logoutEveryAccount} = useSessionApi() const {logoutCurrentAccount} = useSessionApi()
const [pending, setPending] = React.useState(false) const [pending, setPending] = React.useState(false)
const [error, setError] = React.useState<string | undefined>() const [error, setError] = React.useState<string | undefined>()
@@ -44,7 +44,7 @@ function DeactivateAccountDialogInner({
setPending(true) setPending(true)
await agent.com.atproto.server.deactivateAccount({}) await agent.com.atproto.server.deactivateAccount({})
control.close(() => { control.close(() => {
logoutEveryAccount('Deactivated') logoutCurrentAccount('Deactivated')
}) })
} catch (e: any) { } catch (e: any) {
switch (e.message) { switch (e.message) {
@@ -66,7 +66,7 @@ function DeactivateAccountDialogInner({
} finally { } finally {
setPending(false) setPending(false)
} }
}, [agent, control, logoutEveryAccount, _, setPending]) }, [agent, control, logoutCurrentAccount, _, setPending])
return ( return (
<> <>
+3 -3
View File
@@ -23,7 +23,7 @@ export function SignupQueued() {
const insets = useSafeAreaInsets() const insets = useSafeAreaInsets()
const {gtMobile} = useBreakpoints() const {gtMobile} = useBreakpoints()
const onboardingDispatch = useOnboardingDispatch() const onboardingDispatch = useOnboardingDispatch()
const {logoutEveryAccount} = useSessionApi() const {logoutCurrentAccount} = useSessionApi()
const agent = useAgent() const agent = useAgent()
const [isProcessing, setProcessing] = React.useState(false) const [isProcessing, setProcessing] = React.useState(false)
@@ -153,7 +153,7 @@ export function SignupQueued() {
variant="ghost" variant="ghost"
size="large" size="large"
label={_(msg`Log out`)} label={_(msg`Log out`)}
onPress={() => logoutEveryAccount('SignupQueued')}> onPress={() => logoutCurrentAccount('SignupQueued')}>
<ButtonText style={[{color: t.palette.primary_500}]}> <ButtonText style={[{color: t.palette.primary_500}]}>
<Trans>Log out</Trans> <Trans>Log out</Trans>
</ButtonText> </ButtonText>
@@ -182,7 +182,7 @@ export function SignupQueued() {
variant="ghost" variant="ghost"
size="large" size="large"
label={_(msg`Log out`)} label={_(msg`Log out`)}
onPress={() => logoutEveryAccount('SignupQueued')}> onPress={() => logoutCurrentAccount('SignupQueued')}>
<ButtonText style={[{color: t.palette.primary_500}]}> <ButtonText style={[{color: t.palette.primary_500}]}>
<Trans>Log out</Trans> <Trans>Log out</Trans>
</ButtonText> </ButtonText>
+3 -3
View File
@@ -77,7 +77,7 @@ function SettingsAccountCard({
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
const {currentAccount} = useSession() const {currentAccount} = useSession()
const {logoutEveryAccount} = useSessionApi() 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
@@ -109,11 +109,11 @@ function SettingsAccountCard({
testID="signOutBtn" testID="signOutBtn"
onPress={() => { onPress={() => {
if (isNative) { if (isNative) {
logoutEveryAccount('Settings') logoutCurrentAccount('Settings')
resetToTab('HomeTab') resetToTab('HomeTab')
} else { } else {
navigate('Home').then(() => { navigate('Home').then(() => {
logoutEveryAccount('Settings') logoutCurrentAccount('Settings')
}) })
} }
}} }}