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

Commit 139ff8b

Browse files
committed
Close any open modals on logout
Split out from #12666
1 parent 4445461 commit 139ff8b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Modal.tsx

+17-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import { IDeferred, defer, sleep } from "matrix-js-sdk/src/utils";
2222
import { TypedEventEmitter } from "matrix-js-sdk/src/matrix";
2323
import { Glass } from "@vector-im/compound-web";
2424

25-
import dis from "./dispatcher/dispatcher";
25+
import dis, { defaultDispatcher } from "./dispatcher/dispatcher";
2626
import AsyncWrapper from "./AsyncWrapper";
2727
import { Defaultize } from "./@types/common";
28+
import { ActionPayload } from "./dispatcher/payloads";
2829

2930
const DIALOG_CONTAINER_ID = "mx_Dialog_Container";
3031
const STATIC_DIALOG_CONTAINER_ID = "mx_Dialog_StaticContainer";
@@ -114,6 +115,21 @@ export class ModalManager extends TypedEventEmitter<ModalManagerEvent, HandlerMa
114115
return container;
115116
}
116117

118+
public constructor() {
119+
super();
120+
121+
// We never unregister this, but the Modal class is a singleton so there would
122+
// never be an opportunity to do so anyway, except in the entirely theoretical
123+
// scenario of instantiating a non-singleton instance of the Modal class.
124+
defaultDispatcher.register(this.onAction);
125+
}
126+
127+
private onAction = (payload: ActionPayload): void => {
128+
if (payload.action === "logout") {
129+
this.forceCloseAllModals();
130+
}
131+
};
132+
117133
public toggleCurrentDialogVisibility(): void {
118134
const modal = this.getCurrentModal();
119135
if (!modal) return;

0 commit comments

Comments
 (0)