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 @@ -6,6 +6,7 @@ import { logOutActionTypes, useLogOut, + usePrimaryDeviceLogOut, useSecondaryDeviceLogOut, } from 'lib/actions/user-actions.js'; import { useStringForUser } from 'lib/hooks/ens-cache.js'; @@ -159,6 +160,7 @@ +styles: $ReadOnly, +dispatchActionPromise: DispatchActionPromise, +logOut: () => Promise, + +logOutPrimaryDevice: () => Promise, +logOutSecondaryDevice: () => Promise, +staffCanSee: boolean, +stringForUser: ?string, @@ -251,14 +253,21 @@ ); } - let secondaryDeviceLogout; + let experimentalLogoutActions; if (__DEV__) { - secondaryDeviceLogout = ( - + experimentalLogoutActions = ( + <> + + + ); } @@ -313,7 +322,7 @@ {keyserverSelection} {developerTools} - {secondaryDeviceLogout} + {experimentalLogoutActions} { + if (this.loggedOutOrLoggingOut) { + return; + } + // TODO: Add check for primary device + Alert.alert( + 'Log out primary device', + 'Are you sure you want to log out all devices?', + [ + { text: 'No', style: 'cancel' }, + { + text: 'Yes', + onPress: this.logOutPrimaryDevice, + style: 'destructive', + }, + ], + { cancelable: true }, + ); + }; + onPressSecondaryDeviceLogout = () => { if (this.loggedOutOrLoggingOut) { return; @@ -413,6 +442,16 @@ ); } + logOutPrimaryDevice = async () => { + if (this.loggedOutOrLoggingOut) { + return; + } + void this.props.dispatchActionPromise( + logOutActionTypes, + this.props.logOutPrimaryDevice(), + ); + }; + logOutSecondaryDevice = async () => { if (this.loggedOutOrLoggingOut) { return; @@ -497,6 +536,7 @@ const colors = useColors(); const styles = useStyles(unboundStyles); const callLogOut = useLogOut(); + const callPrimaryDeviceLogOut = usePrimaryDeviceLogOut(); const callSecondaryDeviceLogOut = useSecondaryDeviceLogOut(); const dispatchActionPromise = useDispatchActionPromise(); const staffCanSee = useStaffCanSee(); @@ -513,6 +553,7 @@ colors={colors} styles={styles} logOut={callLogOut} + logOutPrimaryDevice={callPrimaryDeviceLogOut} logOutSecondaryDevice={callSecondaryDeviceLogOut} dispatchActionPromise={dispatchActionPromise} staffCanSee={staffCanSee}