From 26427817f2704b674e5cea603786e3d968a53f27 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 10 Jul 2020 08:18:40 -0600 Subject: [PATCH] Fix potential listener conflict with RVS If the RVS ever emits something that contains `trigger: false`, we're pretty screwed, so avoid that. --- src/stores/room-list/RoomListStore2.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stores/room-list/RoomListStore2.ts b/src/stores/room-list/RoomListStore2.ts index f1b26f26ce..05f678160e 100644 --- a/src/stores/room-list/RoomListStore2.ts +++ b/src/stores/room-list/RoomListStore2.ts @@ -63,7 +63,7 @@ export class RoomListStore2 extends AsyncStore { this.checkEnabled(); for (const settingName of this.watchedSettings) SettingsStore.monitorSetting(settingName, null); - RoomViewStore.addListener(this.onRVSUpdate); + RoomViewStore.addListener(() => this.handleRVSUpdate({})); this.algorithm.on(LIST_UPDATED_EVENT, this.onAlgorithmListUpdated); } @@ -97,7 +97,7 @@ export class RoomListStore2 extends AsyncStore { * @param trigger Set to false to prevent a list update from being sent. Should only * be used if the calling code will manually trigger the update. */ - private onRVSUpdate = async ({trigger = true}) => { + private async handleRVSUpdate({trigger = true}) { if (!this.enabled) return; // TODO: Remove with https://github.com/vector-im/riot-web/issues/14231 if (!this.matrixClient) return; // We assume there won't be RVS updates without a client @@ -119,7 +119,7 @@ export class RoomListStore2 extends AsyncStore { } if (trigger) this.updateFn.trigger(); - }; + } protected onDispatch(payload: ActionPayload) { // We do this to intentionally break out of the current event loop task, allowing @@ -144,7 +144,7 @@ export class RoomListStore2 extends AsyncStore { console.log("Regenerating room lists: Startup"); await this.readAndCacheSettingsFromStore(); await this.regenerateAllLists({trigger: false}); - await this.onRVSUpdate({trigger: false}); // fake an RVS update to adjust sticky room, if needed + await this.handleRVSUpdate({trigger: false}); // fake an RVS update to adjust sticky room, if needed this.updateFn.trigger();