Add sign out button to settings profile section (#12666)
* Add sign out button to settings profile section And move the logic for displaying the dialog out of the user menu to somewhere it can be re-used. Also close any open dialog on logout, because otherwise, well... you can guess. * Missing import * Update screenshot * This button doesn't need to be an anchor * Use Flex component * Use new force-close function * More tests
This commit is contained in:
parent
844da7a656
commit
c2c108957e
5 changed files with 86 additions and 28 deletions
|
@ -27,7 +27,7 @@ import { UserTab } from "../views/dialogs/UserTab";
|
|||
import { OpenToTabPayload } from "../../dispatcher/payloads/OpenToTabPayload";
|
||||
import FeedbackDialog from "../views/dialogs/FeedbackDialog";
|
||||
import Modal from "../../Modal";
|
||||
import LogoutDialog from "../views/dialogs/LogoutDialog";
|
||||
import LogoutDialog, { shouldShowLogoutDialog } from "../views/dialogs/LogoutDialog";
|
||||
import SettingsStore from "../../settings/SettingsStore";
|
||||
import { findHighContrastTheme, getCustomTheme, isHighContrastTheme } from "../../theme";
|
||||
import { RovingAccessibleButton } from "../../accessibility/RovingTabIndex";
|
||||
|
@ -288,7 +288,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
|||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
if (await this.shouldShowLogoutDialog()) {
|
||||
if (await shouldShowLogoutDialog(MatrixClientPeg.safeGet())) {
|
||||
Modal.createDialog(LogoutDialog);
|
||||
} else {
|
||||
defaultDispatcher.dispatch({ action: "logout" });
|
||||
|
@ -297,27 +297,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
|||
this.setState({ contextMenuPosition: null }); // also close the menu
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if the `LogoutDialog` should be shown instead of the simple logout flow.
|
||||
* The `LogoutDialog` will check the crypto recovery status of the account and
|
||||
* help the user setup recovery properly if needed.
|
||||
* @private
|
||||
*/
|
||||
private async shouldShowLogoutDialog(): Promise<boolean> {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const crypto = cli?.getCrypto();
|
||||
if (!crypto) return false;
|
||||
|
||||
// If any room is encrypted, we need to show the advanced logout flow
|
||||
const allRooms = cli!.getRooms();
|
||||
for (const room of allRooms) {
|
||||
const isE2e = await crypto.isEncryptionEnabledInRoom(room.roomId);
|
||||
if (isE2e) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private onSignInClick = (): void => {
|
||||
defaultDispatcher.dispatch({ action: "start_login" });
|
||||
this.setState({ contextMenuPosition: null }); // also close the menu
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue