From c8f90be81d5a1d5df687066192b2af649bef77d5 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 8 Jul 2020 18:32:12 -0600 Subject: [PATCH] Ensure the map gets cleared upon logout --- src/stores/room-list/RoomListLayoutStore.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/stores/room-list/RoomListLayoutStore.ts b/src/stores/room-list/RoomListLayoutStore.ts index dd4364f5fc..4d8c98a4f8 100644 --- a/src/stores/room-list/RoomListLayoutStore.ts +++ b/src/stores/room-list/RoomListLayoutStore.ts @@ -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 { private static internalInstance: RoomListLayoutStore; private readonly layoutMap = new Map(); + 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 { + // 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 { + return Promise.resolve(); + } } window.mx_RoomListLayoutStore = RoomListLayoutStore.instance;