From e28d2a2299cec10a6a13e19e07351b991df065bf Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 24 Jan 2022 14:45:52 +0000 Subject: [PATCH] Always emit a space filter update when the space is actually changed (#7611) --- src/stores/room-list/filters/SpaceFilterCondition.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/stores/room-list/filters/SpaceFilterCondition.ts b/src/stores/room-list/filters/SpaceFilterCondition.ts index b2d86b459a..90bf22ed20 100644 --- a/src/stores/room-list/filters/SpaceFilterCondition.ts +++ b/src/stores/room-list/filters/SpaceFilterCondition.ts @@ -20,7 +20,7 @@ import { Room } from "matrix-js-sdk/src/models/room"; import { FILTER_CHANGED, FilterKind, IFilterCondition } from "./IFilterCondition"; import { IDestroyable } from "../../../utils/IDestroyable"; import SpaceStore from "../../spaces/SpaceStore"; -import { MetaSpace, SpaceKey } from "../../spaces"; +import { isMetaSpace, MetaSpace, SpaceKey } from "../../spaces"; import { setHasDiff } from "../../../utils/sets"; import SettingsStore from "../../../settings/SettingsStore"; @@ -44,7 +44,7 @@ export class SpaceFilterCondition extends EventEmitter implements IFilterConditi return SpaceStore.instance.isRoomInSpace(this.space, room.roomId); } - private onStoreUpdate = async (): Promise => { + private onStoreUpdate = async (forceUpdate = false): Promise => { const beforeRoomIds = this.roomIds; // clone the set as it may be mutated by the space store internally this.roomIds = new Set(SpaceStore.instance.getSpaceFilteredRoomIds(this.space)); @@ -54,10 +54,11 @@ export class SpaceFilterCondition extends EventEmitter implements IFilterConditi this.userIds = new Set(SpaceStore.instance.getSpaceFilteredUserIds(this.space)); const beforeShowPeopleInSpace = this.showPeopleInSpace; - this.showPeopleInSpace = this.space[0] !== "!" || + this.showPeopleInSpace = isMetaSpace(this.space[0]) || SettingsStore.getValue("Spaces.showPeopleInSpace", this.space); - if (beforeShowPeopleInSpace !== this.showPeopleInSpace || + if (forceUpdate || + beforeShowPeopleInSpace !== this.showPeopleInSpace || setHasDiff(beforeRoomIds, this.roomIds) || setHasDiff(beforeUserIds, this.userIds) ) { @@ -73,7 +74,7 @@ export class SpaceFilterCondition extends EventEmitter implements IFilterConditi public updateSpace(space: SpaceKey) { SpaceStore.instance.off(this.space, this.onStoreUpdate); SpaceStore.instance.on(this.space = space, this.onStoreUpdate); - this.onStoreUpdate(); // initial update from the change to the space + this.onStoreUpdate(true); // initial update from the change to the space } public destroy(): void {