From efb8c89433a1aee5fea49dfda3c8cc2e82e149cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 26 Mar 2021 08:13:50 +0100 Subject: [PATCH] Don't save if isSpaceRoom() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/stores/SpaceStore.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/stores/SpaceStore.tsx b/src/stores/SpaceStore.tsx index 3d476f7077..ef12640438 100644 --- a/src/stores/SpaceStore.tsx +++ b/src/stores/SpaceStore.tsx @@ -490,15 +490,20 @@ export class SpaceStoreClass extends AsyncStoreWithClient { if (!SettingsStore.getValue("feature_spaces")) return; switch (payload.action) { case "view_room": { - // persist last viewed room from a space - const activeSpaceId = this.activeSpace?.roomId || LAST_VIEWED_ROOMS_HOME; - const lastViewedRooms = JSON.parse(window.localStorage.getItem(LAST_VIEWED_ROOMS)) || {}; - - lastViewedRooms[activeSpaceId] = payload.room_id; - window.localStorage.setItem(LAST_VIEWED_ROOMS, JSON.stringify(lastViewedRooms)); - const room = this.matrixClient?.getRoom(payload.room_id); + // persist last viewed room from a space + + // We don't want to save if the room is a + // space room since it can cause problems + if (!room.isSpaceRoom()) { + const activeSpaceId = this.activeSpace?.roomId || LAST_VIEWED_ROOMS_HOME; + const lastViewedRooms = JSON.parse(window.localStorage.getItem(LAST_VIEWED_ROOMS)) || {}; + + lastViewedRooms[activeSpaceId] = payload.room_id; + window.localStorage.setItem(LAST_VIEWED_ROOMS, JSON.stringify(lastViewedRooms)); + } + if (room?.getMyMembership() === "join") { if (room.isSpaceRoom()) { this.setActiveSpace(room);