Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix logout can take ages #12191

Merged
merged 6 commits into from
Feb 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions src/components/structures/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,36 @@
ev.preventDefault();
ev.stopPropagation();

const cli = MatrixClientPeg.get();
if (!cli || !cli.isCryptoEnabled() || !(await cli.exportRoomKeys())?.length) {
// log out without user prompt if they have no local megolm sessions
defaultDispatcher.dispatch({ action: "logout" });
} else {
if (await this.shouldShowLogoutDialog()) {
Modal.createDialog(LogoutDialog);
} else {
defaultDispatcher.dispatch({ action: "logout" });
}

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 in allRooms) {
const isE2e = await crypto.isEncryptionEnabledInRoom(room.roomId);

Check failure on line 284 in src/components/structures/UserMenu.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Property 'roomId' does not exist on type 'string'.
if (isE2e) return true;
}

return false;
}

private onSignInClick = (): void => {
defaultDispatcher.dispatch({ action: "start_login" });
this.setState({ contextMenuPosition: null }); // also close the menu
Expand Down
Loading