From ecd9b8d6deb03bd1b9ed2e6863e2bdc5b82f0b4b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 21 Apr 2021 09:01:22 +0100 Subject: [PATCH] Fix issue with spaces context switching looping and breaking --- src/stores/SpaceStore.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stores/SpaceStore.tsx b/src/stores/SpaceStore.tsx index 290caba9d4..6ec60600a0 100644 --- a/src/stores/SpaceStore.tsx +++ b/src/stores/SpaceStore.tsx @@ -124,11 +124,13 @@ export class SpaceStoreClass extends AsyncStoreWithClient { 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({ @@ -513,6 +515,10 @@ export class SpaceStoreClass extends AsyncStoreWithClient { case "view_room": { const room = this.matrixClient?.getRoom(payload.room_id); + // 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 (payload.context_switch) break; + // persist last viewed room from a space if (room) { window.localStorage.setItem(getLastViewedRoomsStorageKey(this.activeSpace), payload.room_id);