Ensure the map gets cleared upon logout
This commit is contained in:
parent
c5812d6c27
commit
c8f90be81d
1 changed files with 20 additions and 1 deletions
|
@ -16,12 +16,21 @@ limitations under the License.
|
|||
|
||||
import { TagID } from "./models";
|
||||
import { ListLayout } from "./ListLayout";
|
||||
import { AsyncStoreWithClient } from "../AsyncStoreWithClient";
|
||||
import defaultDispatcher from "../../dispatcher/dispatcher";
|
||||
import { ActionPayload } from "../../dispatcher/payloads";
|
||||
|
||||
export default class RoomListLayoutStore {
|
||||
interface IState {}
|
||||
|
||||
export default class RoomListLayoutStore extends AsyncStoreWithClient<IState> {
|
||||
private static internalInstance: RoomListLayoutStore;
|
||||
|
||||
private readonly layoutMap = new Map<TagID, ListLayout>();
|
||||
|
||||
constructor() {
|
||||
super(defaultDispatcher);
|
||||
}
|
||||
|
||||
public ensureLayoutExists(tagId: TagID) {
|
||||
if (!this.layoutMap.has(tagId)) {
|
||||
this.layoutMap.set(tagId, new ListLayout(tagId));
|
||||
|
@ -49,6 +58,16 @@ export default class RoomListLayoutStore {
|
|||
}
|
||||
return RoomListLayoutStore.internalInstance;
|
||||
}
|
||||
|
||||
protected async onNotReady(): Promise<any> {
|
||||
// On logout, clear the map.
|
||||
this.layoutMap.clear();
|
||||
}
|
||||
|
||||
// We don't need this function, but our contract says we do
|
||||
protected async onAction(payload: ActionPayload): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
window.mx_RoomListLayoutStore = RoomListLayoutStore.instance;
|
||||
|
|
Loading…
Reference in a new issue