diff --git a/native/profile/profile-screen.react.js b/native/profile/profile-screen.react.js --- a/native/profile/profile-screen.react.js +++ b/native/profile/profile-screen.react.js @@ -3,7 +3,11 @@ import * as React from 'react'; import { View, Text, Platform, ScrollView } from 'react-native'; -import { logOutActionTypes, useLogOut } from 'lib/actions/user-actions.js'; +import { + logOutActionTypes, + useLogOut, + useSecondaryDeviceLogOut, +} from 'lib/actions/user-actions.js'; import { useStringForUser } from 'lib/hooks/ens-cache.js'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js'; import { accountHasPassword } from 'lib/shared/account-utils.js'; @@ -155,6 +159,7 @@ +styles: $ReadOnly, +dispatchActionPromise: DispatchActionPromise, +logOut: () => Promise, + +logOutSecondaryDevice: () => Promise, +staffCanSee: boolean, +stringForUser: ?string, +isAccountWithPassword: boolean, @@ -246,6 +251,17 @@ ); } + let secondaryDeviceLogout; + if (__DEV__) { + secondaryDeviceLogout = ( + + ); + } + return ( {developerTools} + {secondaryDeviceLogout} { + if (this.loggedOutOrLoggingOut) { + return; + } + // TODO: Add check for secondary device + Alert.alert( + 'Log out secondary device', + 'Are you sure you want to log out this device?', + [ + { text: 'No', style: 'cancel' }, + { + text: 'Yes', + onPress: this.logOutSecondaryDevice, + style: 'destructive', + }, + ], + { cancelable: true }, + ); + }; + logOutWithoutDeletingNativeCredentialsWrapper = () => { if (this.loggedOutOrLoggingOut) { return; @@ -376,6 +413,16 @@ ); } + logOutSecondaryDevice = async () => { + if (this.loggedOutOrLoggingOut) { + return; + } + void this.props.dispatchActionPromise( + logOutActionTypes, + this.props.logOutSecondaryDevice(), + ); + }; + async deleteNativeCredentials() { await deleteNativeCredentialsFor(); } @@ -450,6 +497,7 @@ const colors = useColors(); const styles = useStyles(unboundStyles); const callLogOut = useLogOut(); + const callSecondaryDeviceLogOut = useSecondaryDeviceLogOut(); const dispatchActionPromise = useDispatchActionPromise(); const staffCanSee = useStaffCanSee(); const stringForUser = useStringForUser(currentUserInfo); @@ -465,6 +513,7 @@ colors={colors} styles={styles} logOut={callLogOut} + logOutSecondaryDevice={callSecondaryDeviceLogOut} dispatchActionPromise={dispatchActionPromise} staffCanSee={staffCanSee} stringForUser={stringForUser}