From f62e2c0042eb2bb9a76eca417aff46bc0010a4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 26 Mar 2021 13:44:51 +0100 Subject: [PATCH] Use compound keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/stores/SpaceStore.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/stores/SpaceStore.tsx b/src/stores/SpaceStore.tsx index f07616aed3..c58340356d 100644 --- a/src/stores/SpaceStore.tsx +++ b/src/stores/SpaceStore.tsx @@ -117,8 +117,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient { // view last selected room from space const spaceId = space?.roomId || LAST_VIEWED_ROOMS_HOME; - const lastViewedRooms = JSON.parse(window.localStorage.getItem(LAST_VIEWED_ROOMS)) || {}; - const roomId = lastViewedRooms[spaceId]; + const roomId = window.localStorage.getItem(`${LAST_VIEWED_ROOMS}_${spaceId}`); if (roomId) { defaultDispatcher.dispatch({ @@ -500,10 +499,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient { // space room since it can cause problems if (room && !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)); + window.localStorage.setItem(`${LAST_VIEWED_ROOMS}_${activeSpaceId}`, payload.room_id); } if (room?.getMyMembership() === "join") {