Skip to content

Commit

Permalink
[native][web] Merge logout buttons for old and new flows
Browse files Browse the repository at this point in the history
Summary:
Address [[ https://linear.app/comm/issue/ENG-9688/merge-old-and-new-logout-buttons | ENG-9688 ]].

- Removed the experimental buttons for new logout flows
- Main logout button behavior depends on `usingRestoreFlow`:
  - legacy logout (current behavior) if false
  - Primary/secondary logout if true

Depends on D14146

Test Plan: Changed the flag true/false and pressed logout button. Made sure correct procedure is executed

Reviewers: kamil, tomek

Reviewed By: kamil

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D14147
  • Loading branch information
barthap committed Dec 16, 2024
1 parent d0002b3 commit 0f7e12d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 38 deletions.
19 changes: 5 additions & 14 deletions native/profile/profile-screen.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,6 @@ class ProfileScreen extends React.PureComponent<Props> {
);
}

let experimentalLogoutActions;
if (__DEV__) {
experimentalLogoutActions = (
<>
<ProfileRow
danger
content="Log out (new flow)"
onPress={this.onPressNewLogout}
/>
</>
);
}

let dmActions;
if (staffCanSee) {
dmActions = (
Expand Down Expand Up @@ -353,7 +340,6 @@ class ProfileScreen extends React.PureComponent<Props> {
{keyserverSelection}
<ProfileRow content="Build info" onPress={this.onPressBuildInfo} />
{developerTools}
{experimentalLogoutActions}
{dmActions}
</View>
<View style={this.props.styles.unpaddedSection}>
Expand All @@ -372,6 +358,11 @@ class ProfileScreen extends React.PureComponent<Props> {
if (this.loggedOutOrLoggingOut) {
return;
}
if (usingRestoreFlow) {
this.onPressNewLogout();
return;
}

if (!this.props.isAccountWithPassword) {
Alert.alert(
'Log out',
Expand Down
37 changes: 13 additions & 24 deletions web/settings/account-settings.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import {
createOlmSessionsWithOwnDevices,
getContentSigningKey,
} from 'lib/utils/crypto-utils.js';
import { isDev } from 'lib/utils/dev-utils.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import { usingRestoreFlow } from 'lib/utils/services-utils.js';

import css from './account-settings.css';
import AppearanceChangeModal from './appearance-change-modal.react.js';
Expand Down Expand Up @@ -54,18 +54,20 @@ function AccountSettings(): React.Node {

const sendSecondaryDeviceLogoutRequest = useSecondaryDeviceLogOut();
const dispatchActionPromise = useDispatchActionPromise();
const logOutUser = React.useCallback(
() => dispatchActionPromise(logOutActionTypes, sendLogoutRequest()),
[dispatchActionPromise, sendLogoutRequest],
);
const logOutSecondaryDevice = React.useCallback(
() =>
dispatchActionPromise(
const logOutUser = React.useCallback(() => {
if (usingRestoreFlow) {
return dispatchActionPromise(
logOutActionTypes,
sendSecondaryDeviceLogoutRequest(),
),
[dispatchActionPromise, sendSecondaryDeviceLogoutRequest],
);
);
}
return dispatchActionPromise(logOutActionTypes, sendLogoutRequest());
}, [
dispatchActionPromise,
sendLogoutRequest,
sendSecondaryDeviceLogoutRequest,
]);

const identityContext = React.useContext(IdentityClientContext);

const userID = useSelector(state => state.currentUserInfo?.id);
Expand Down Expand Up @@ -170,18 +172,6 @@ function AccountSettings(): React.Node {
return null;
}

let experimentalLogOutSection;
if (isDev) {
experimentalLogOutSection = (
<li>
<span>Log out secondary device</span>
<Button variant="text" onClick={logOutSecondaryDevice}>
<p className={css.buttonText}>Log out</p>
</Button>
</li>
);
}

let preferences;
if (staffCanSee) {
preferences = (
Expand Down Expand Up @@ -310,7 +300,6 @@ function AccountSettings(): React.Node {
<p className={css.buttonText}>Log out</p>
</Button>
</li>
{experimentalLogOutSection}
<li>
<span>Friend List</span>
<Button variant="text" onClick={openFriendList}>
Expand Down

0 comments on commit 0f7e12d

Please sign in to comment.