RoomListStore removeFilter skip triggering update if nothing changed

This commit is contained in:
Michael Telatynski 2021-07-27 17:53:03 +01:00
parent 12461a79e1
commit 8c073a6439

View File

@ -711,6 +711,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
} }
let promise = Promise.resolve(); let promise = Promise.resolve();
let idx = this.filterConditions.indexOf(filter); let idx = this.filterConditions.indexOf(filter);
let removed = false;
if (idx >= 0) { if (idx >= 0) {
this.filterConditions.splice(idx, 1); this.filterConditions.splice(idx, 1);
@ -721,14 +722,20 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
if (SpaceStore.spacesEnabled) { if (SpaceStore.spacesEnabled) {
promise = this.recalculatePrefiltering(); promise = this.recalculatePrefiltering();
} }
removed = true;
} }
idx = this.prefilterConditions.indexOf(filter); idx = this.prefilterConditions.indexOf(filter);
if (idx >= 0) { if (idx >= 0) {
filter.off(FILTER_CHANGED, this.onPrefilterUpdated); filter.off(FILTER_CHANGED, this.onPrefilterUpdated);
this.prefilterConditions.splice(idx, 1); this.prefilterConditions.splice(idx, 1);
promise = this.recalculatePrefiltering(); promise = this.recalculatePrefiltering();
removed = true;
}
if (removed) {
promise.then(() => this.updateFn.trigger());
} }
promise.then(() => this.updateFn.trigger());
} }
/** /**