Fix open room from search always open same space
authorAjay Bura <32841439+ajbura@users.noreply.github.com>
Sun, 21 Aug 2022 03:21:13 +0000 (08:51 +0530)
committerAjay Bura <32841439+ajbura@users.noreply.github.com>
Sun, 21 Aug 2022 03:21:13 +0000 (08:51 +0530)
src/client/state/navigation.js

index 5bed0956ca499cf9e53e568a7cca5105dc97a823..7b13dd187c56d7e39c7c1006c2f7924fd829f138 100644 (file)
@@ -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) {