From a5ba0cad1fa7f2814c3c9127014ac3706d6e3fcf Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 10 Jul 2020 08:13:23 -0600 Subject: [PATCH] Rename to trigger and add docs --- src/stores/room-list/RoomListStore2.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/stores/room-list/RoomListStore2.ts b/src/stores/room-list/RoomListStore2.ts index 5591de67b1..f1b26f26ce 100644 --- a/src/stores/room-list/RoomListStore2.ts +++ b/src/stores/room-list/RoomListStore2.ts @@ -92,7 +92,12 @@ export class RoomListStore2 extends AsyncStore { await this.updateAlgorithmInstances(); } - private onRVSUpdate = async (quiet = false) => { + /** + * Handles suspected RoomViewStore changes. + * @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}) => { 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 @@ -113,7 +118,7 @@ export class RoomListStore2 extends AsyncStore { } } - if (!quiet) this.updateFn.trigger(); + if (trigger) this.updateFn.trigger(); }; protected onDispatch(payload: ActionPayload) { @@ -138,8 +143,8 @@ export class RoomListStore2 extends AsyncStore { // Update any settings here, as some may have happened before we were logically ready. console.log("Regenerating room lists: Startup"); await this.readAndCacheSettingsFromStore(); - await this.regenerateAllLists(true); - await this.onRVSUpdate(true); // fake an RVS update to adjust sticky room, if needed + await this.regenerateAllLists({trigger: false}); + await this.onRVSUpdate({trigger: false}); // fake an RVS update to adjust sticky room, if needed this.updateFn.trigger(); @@ -166,7 +171,7 @@ export class RoomListStore2 extends AsyncStore { console.log("Regenerating room lists: Settings changed"); await this.readAndCacheSettingsFromStore(); - await this.regenerateAllLists(true); // regenerate the lists now + await this.regenerateAllLists({trigger: false}); // regenerate the lists now this.updateFn.trigger(); } } @@ -474,7 +479,12 @@ export class RoomListStore2 extends AsyncStore { this.updateFn.mark(); }; - private async regenerateAllLists(quiet = false) { + /** + * Regenerates the room whole room list, discarding any previous results. + * @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 async regenerateAllLists({trigger = true}) { console.warn("Regenerating all room lists"); const sorts: ITagSortingMap = {}; @@ -499,7 +509,7 @@ export class RoomListStore2 extends AsyncStore { this.initialListsGenerated = true; - if (!quiet) this.updateFn.trigger(); + if (trigger) this.updateFn.trigger(); } public addFilter(filter: IFilterCondition): void {