mirror of https://github.com/vector-im/riot-web
Merge pull request #5893 from matrix-org/t3chguy/fix/16978
Fix spaces filtering sometimes lagging behind or behaving oddlypull/21833/head
commit
8373b0e69c
|
@ -448,11 +448,11 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||
}
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -42,10 +42,16 @@ export class SpaceFilterCondition extends EventEmitter implements IFilterConditi
|
|||
|
||||
private onStoreUpdate = async (): Promise<void> => {
|
||||
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);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue