From a5878e9de6b6bf281839c4014f376fdd8b5e54fb Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sat, 20 Aug 2022 13:12:29 +0530 Subject: [PATCH] Fix room remain selected on leave --- src/client/event/roomList.js | 10 ++++++++++ src/client/state/navigation.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/client/event/roomList.js b/src/client/event/roomList.js index bc40a4c5..cd401c1f 100644 --- a/src/client/event/roomList.js +++ b/src/client/event/roomList.js @@ -4,6 +4,16 @@ import { selectTab, selectSpace, selectRoom } from '../action/navigation'; function initRoomListListener(roomList) { const listenRoomLeave = (roomId) => { + const parents = roomList.roomIdToParents.get(roomId); + if (parents) { + [...parents].forEach((pId) => { + const data = navigation.spaceToRoom.get(pId); + if (data?.roomId === roomId) { + navigation.spaceToRoom.delete(pId); + } + }); + } + if (navigation.selectedRoomId === roomId) { selectRoom(null); } diff --git a/src/client/state/navigation.js b/src/client/state/navigation.js index 8e8f721b..39d3ce3c 100644 --- a/src/client/state/navigation.js +++ b/src/client/state/navigation.js @@ -282,7 +282,7 @@ class Navigation extends EventEmitter { this._selectSpace(action.roomId, false); }, [cons.actions.navigation.SELECT_ROOM]: () => { - this._selectTabWithRoom(action.roomId); + if (action.roomId) this._selectTabWithRoom(action.roomId); this._selectRoom(action.roomId, action.eventId); }, [cons.actions.navigation.OPEN_SPACE_SETTINGS]: () => {