From ace8d59a2af11c8dcd78d1c0a63a292ee4e9124e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Apr 2021 13:12:28 +0100 Subject: [PATCH 1/2] Fix Spaces NPE when a room with no tags gains its first tag --- src/stores/SpaceStore.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stores/SpaceStore.tsx b/src/stores/SpaceStore.tsx index 290caba9d4..63a95d90c7 100644 --- a/src/stores/SpaceStore.tsx +++ b/src/stores/SpaceStore.tsx @@ -446,11 +446,11 @@ export class SpaceStoreClass extends AsyncStoreWithClient { } }; - private onRoomAccountData = (ev: MatrixEvent, room: Room, lastEvent: MatrixEvent) => { + private onRoomAccountData = (ev: MatrixEvent, room: Room, lastEvent?: MatrixEvent) => { if (ev.getType() === EventType.Tag && !room.isSpaceRoom()) { // If the room was in favourites and now isn't or the opposite then update its position in the trees - const oldTags = lastEvent.getContent()?.tags; - const newTags = ev.getContent()?.tags; + const oldTags = lastEvent?.getContent()?.tags || {}; + const newTags = ev.getContent()?.tags || {}; if (!!oldTags[DefaultTagID.Favourite] !== !!newTags[DefaultTagID.Favourite]) { this.onRoomUpdate(room); } From 1507f64f2bf954260460ee6ac518dc13537b5dc4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 21 Apr 2021 08:52:56 +0100 Subject: [PATCH 2/2] Fix spaces filtering sometimes lagging behind or behaving oddly --- src/stores/room-list/filters/SpaceFilterCondition.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stores/room-list/filters/SpaceFilterCondition.ts b/src/stores/room-list/filters/SpaceFilterCondition.ts index ad0ab88868..43bdcb3879 100644 --- a/src/stores/room-list/filters/SpaceFilterCondition.ts +++ b/src/stores/room-list/filters/SpaceFilterCondition.ts @@ -42,10 +42,16 @@ export class SpaceFilterCondition extends EventEmitter implements IFilterConditi private onStoreUpdate = async (): Promise => { const beforeRoomIds = this.roomIds; - this.roomIds = SpaceStore.instance.getSpaceFilteredRoomIds(this.space); + // clone the set as it may be mutated by the space store internally + this.roomIds = new Set(SpaceStore.instance.getSpaceFilteredRoomIds(this.space)); if (setHasDiff(beforeRoomIds, this.roomIds)) { this.emit(FILTER_CHANGED); + // XXX: Room List Store has a bug where updates to the pre-filter during a local echo of a + // tags transition seem to be ignored, so refire in the next tick to work around it + setImmediate(() => { + this.emit(FILTER_CHANGED); + }); } };