From 7ff76b250010b6c71a456895452a0ad1fd31d568 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 18 Jan 2021 20:28:09 -0700 Subject: [PATCH] Don't forget to run cleanup --- src/stores/widgets/WidgetLayoutStore.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/stores/widgets/WidgetLayoutStore.ts b/src/stores/widgets/WidgetLayoutStore.ts index 4065dd2469..94d77df78b 100644 --- a/src/stores/widgets/WidgetLayoutStore.ts +++ b/src/stores/widgets/WidgetLayoutStore.ts @@ -103,6 +103,9 @@ export class WidgetLayoutStore extends ReadyWatchingStore { }; } = {}; + private pinnedRef: string; + private layoutRef: string; + private constructor() { super(defaultDispatcher); } @@ -126,13 +129,17 @@ export class WidgetLayoutStore extends ReadyWatchingStore { this.updateAllRooms(); this.matrixClient.on("RoomState.events", this.updateRoomFromState); - SettingsStore.watchSetting("Widgets.pinned", null, this.updateFromSettings); - SettingsStore.watchSetting("Widgets.layout", null, this.updateFromSettings); + this.pinnedRef = SettingsStore.watchSetting("Widgets.pinned", null, this.updateFromSettings); + this.layoutRef = SettingsStore.watchSetting("Widgets.layout", null, this.updateFromSettings); WidgetStore.instance.on(UPDATE_EVENT, this.updateAllRooms); } protected async onNotReady(): Promise { this.byRoom = {}; + + SettingsStore.unwatchSetting(this.pinnedRef); + SettingsStore.unwatchSetting(this.layoutRef); + WidgetStore.instance.off(UPDATE_EVENT, this.updateAllRooms); } private updateAllRooms = () => {