Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/spaces-stability

 Conflicts:
	src/stores/SpaceStore.tsx
This commit is contained in:
Michael Telatynski 2021-04-22 08:24:19 +01:00
commit e1ba04716e
46 changed files with 1353 additions and 244 deletions

View file

@ -125,11 +125,13 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
defaultDispatcher.dispatch({
action: "view_room",
room_id: roomId,
context_switch: true,
});
} else if (space) {
defaultDispatcher.dispatch({
action: "view_room",
room_id: space.roomId,
context_switch: true,
});
} else {
defaultDispatcher.dispatch({
@ -448,11 +450,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);
}
@ -514,7 +516,12 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
switch (payload.action) {
case "view_room": {
const room = this.matrixClient?.getRoom(payload.room_id);
if (!room) break;
// Don't auto-switch rooms when reacting to a context-switch
// as this is not helpful and can create loops of rooms/space switching
if (!room || payload.context_switch) break;
// persist last viewed room from a space
if (room.isSpaceRoom()) {
this.setActiveSpace(room);

View file

@ -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);
});
}
};