When accepting DM from People metaspace don't switch to Home (#7272)
This commit is contained in:
parent
37bf85489d
commit
3b9e39ffca
2 changed files with 13 additions and 17 deletions
|
@ -605,23 +605,22 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
private switchToRelatedSpace = (roomId: string) => {
|
private switchToRelatedSpace = (roomId: string) => {
|
||||||
if (this.suggestedRooms.find(r => r.room_id === roomId)) return;
|
if (this.suggestedRooms.find(r => r.room_id === roomId)) return;
|
||||||
|
|
||||||
let parent = this.getCanonicalParent(roomId);
|
// try to find the canonical parent first
|
||||||
|
let parent: SpaceKey = this.getCanonicalParent(roomId)?.roomId;
|
||||||
|
|
||||||
|
// otherwise, try to find a root space which contains this room
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
parent = this.rootSpaces.find(s => this.spaceFilteredRooms.get(s.roomId)?.has(roomId));
|
parent = this.rootSpaces.find(s => this.spaceFilteredRooms.get(s.roomId)?.has(roomId))?.roomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// otherwise, try to find a metaspace which contains this room
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
const parentIds = Array.from(this.parentMap.get(roomId) || []);
|
// search meta spaces in reverse as Home is the first and least specific one
|
||||||
for (const parentId of parentIds) {
|
parent = [...this.enabledMetaSpaces].reverse().find(s => this.getSpaceFilteredRoomIds(s).has(roomId));
|
||||||
const room = this.matrixClient.getRoom(parentId);
|
|
||||||
if (room) {
|
|
||||||
parent = room;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't trigger a context switch when we are switching a space to match the chosen room
|
// don't trigger a context switch when we are switching a space to match the chosen room
|
||||||
this.setActiveSpace(parent?.roomId ?? MetaSpace.Home, false); // TODO
|
this.setActiveSpace(parent ?? MetaSpace.Home, false); // TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
private onRoom = (room: Room, newMembership?: string, oldMembership?: string) => {
|
private onRoom = (room: Room, newMembership?: string, oldMembership?: string) => {
|
||||||
|
@ -848,10 +847,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
// Don't context switch when navigating to the space room
|
// Don't context switch when navigating to the space room
|
||||||
// as it will cause you to end up in the wrong room
|
// as it will cause you to end up in the wrong room
|
||||||
this.setActiveSpace(room.roomId, false);
|
this.setActiveSpace(room.roomId, false);
|
||||||
} else if (
|
} else if (!this.getSpaceFilteredRoomIds(this.activeSpace).has(roomId)) {
|
||||||
(!this.allRoomsInHome || this.activeSpace[0] === "!") &&
|
|
||||||
!this.getSpaceFilteredRoomIds(this.activeSpace).has(roomId)
|
|
||||||
) {
|
|
||||||
this.switchToRelatedSpace(roomId);
|
this.switchToRelatedSpace(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -810,11 +810,11 @@ describe("SpaceStore", () => {
|
||||||
expect(store.activeSpace).toBe(space1);
|
expect(store.activeSpace).toBe(space1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("switch to home for orphaned room", async () => {
|
it("switch to other rooms for orphaned room", async () => {
|
||||||
viewRoom(room1);
|
viewRoom(room1);
|
||||||
store.setActiveSpace(space1, false);
|
store.setActiveSpace(space1, false);
|
||||||
viewRoom(orphan1);
|
viewRoom(orphan1);
|
||||||
expect(store.activeSpace).toBe(MetaSpace.Home);
|
expect(store.activeSpace).toBe(MetaSpace.Orphans);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("switch to first space when selected metaspace is disabled", async () => {
|
it("switch to first space when selected metaspace is disabled", async () => {
|
||||||
|
|
Loading…
Reference in a new issue