Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 202dfd4

Browse files
authored
Merge pull request #5976 from matrix-org/t3chguy/fix/17153
Improve performance of search all spaces and space switching
2 parents 3e1265b + 7f396be commit 202dfd4

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/stores/room-list/RoomListStore.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
668668
* and thus might not cause an update to the store immediately.
669669
* @param {IFilterCondition} filter The filter condition to add.
670670
*/
671-
public addFilter(filter: IFilterCondition): void {
671+
public async addFilter(filter: IFilterCondition): Promise<void> {
672672
if (SettingsStore.getValue("advancedRoomListLogging")) {
673673
// TODO: Remove debug: https://github.com/vector-im/element-web/issues/14602
674674
console.log("Adding filter condition:", filter);
@@ -680,12 +680,14 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
680680
promise = this.recalculatePrefiltering();
681681
} else {
682682
this.filterConditions.push(filter);
683-
if (this.algorithm) {
684-
this.algorithm.addFilterCondition(filter);
685-
}
686683
// Runtime filters with spaces disable prefiltering for the search all spaces effect
687684
if (SettingsStore.getValue("feature_spaces")) {
688-
promise = this.recalculatePrefiltering();
685+
// this has to be awaited so that `setKnownRooms` is called in time for the `addFilterCondition` below
686+
// this way the runtime filters are only evaluated on one dataset and not both.
687+
await this.recalculatePrefiltering();
688+
}
689+
if (this.algorithm) {
690+
this.algorithm.addFilterCondition(filter);
689691
}
690692
}
691693
promise.then(() => this.updateFn.trigger());

src/stores/room-list/algorithms/Algorithm.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,8 @@ export class Algorithm extends EventEmitter {
577577

578578
await this.generateFreshTags(newTags);
579579

580-
this.cachedRooms = newTags;
580+
this.cachedRooms = newTags; // this recalculates the filtered rooms for us
581581
this.updateTagsFromCache();
582-
this.recalculateFilteredRooms();
583582

584583
// Now that we've finished generation, we need to update the sticky room to what
585584
// it was. It's entirely possible that it changed lists though, so if it did then

0 commit comments

Comments
 (0)