From 76c16ce294b78a8935c4853d29b964d8e24e5c97 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sun, 21 Aug 2022 08:51:13 +0530 Subject: [PATCH] Fix open room from search always open same space --- src/client/state/navigation.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/client/state/navigation.js b/src/client/state/navigation.js index 5bed0956..7b13dd18 100644 --- a/src/client/state/navigation.js +++ b/src/client/state/navigation.js @@ -39,7 +39,7 @@ class Navigation extends EventEmitter { } _mapRoomToSpace(roomId) { - const { roomList } = this.initMatrix; + const { roomList, accountData } = this.initMatrix; if ( this.selectedTab === cons.tabs.HOME && roomList.rooms.has(roomId) @@ -61,13 +61,21 @@ class Navigation extends EventEmitter { const parents = roomList.roomIdToParents.get(roomId); if (!parents) return; - - [...parents].forEach((pId) => { - this.spaceToRoom.set(pId, { + if (parents.has(this.selectedSpaceId)) { + this.spaceToRoom.set(this.selectedSpaceId, { roomId, timestamp: Date.now(), }); - }); + } else if (accountData.categorizedSpaces.has(this.selectedSpaceId)) { + const categories = roomList.getCategorizedSpaces([this.selectedSpaceId]); + const parent = [...parents].find((pId) => categories.has(pId)); + if (parent) { + this.spaceToRoom.set(parent, { + roomId, + timestamp: Date.now(), + }); + } + } } _selectRoom(roomId, eventId) {