Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit f0e61e6

Browse files
committed
short circuit automatic switch to related space behaviour and fix tests
1 parent 9d9dce7 commit f0e61e6

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/stores/SpaceStore.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
535535
// Don't context switch when navigating to the space room
536536
// as it will cause you to end up in the wrong room
537537
this.setActiveSpace(room, false);
538-
} else if (!this.getSpaceFilteredRoomIds(this.activeSpace).has(roomId)) {
538+
} else if (this.activeSpace && !this.getSpaceFilteredRoomIds(this.activeSpace).has(roomId)) {
539539
this.switchToRelatedSpace(roomId);
540540
}
541541

test/stores/SpaceStore-test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,14 +641,14 @@ describe("SpaceStore", () => {
641641

642642
it("switch to canonical parent space for room", async () => {
643643
viewRoom(room1);
644-
await store.setActiveSpace(null, false);
644+
await store.setActiveSpace(client.getRoom(space2), false);
645645
viewRoom(room2);
646646
expect(store.activeSpace).toBe(client.getRoom(space2));
647647
});
648648

649649
it("switch to first containing space for room", async () => {
650650
viewRoom(room2);
651-
await store.setActiveSpace(null, false);
651+
await store.setActiveSpace(client.getRoom(space2), false);
652652
viewRoom(room1);
653653
expect(store.activeSpace).toBe(client.getRoom(space1));
654654
});
@@ -659,6 +659,13 @@ describe("SpaceStore", () => {
659659
viewRoom(orphan1);
660660
expect(store.activeSpace).toBeNull();
661661
});
662+
663+
it("when switching rooms in the all rooms home space don't switch to related space", async () => {
664+
viewRoom(room2);
665+
await store.setActiveSpace(null, false);
666+
viewRoom(room1);
667+
expect(store.activeSpace).toBeNull();
668+
});
662669
});
663670

664671
describe("traverseSpace", () => {

0 commit comments

Comments
 (0)