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

Commit 4279e99

Browse files
committed
Improve performance of search all spaces and space switching
1 parent 2bf931b commit 4279e99

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ export class Algorithm extends EventEmitter {
579579

580580
this.cachedRooms = newTags;
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)