diff --git a/src/domain/navigation/index.js b/src/domain/navigation/index.js index 2f039eef..6ce63ffd 100644 --- a/src/domain/navigation/index.js +++ b/src/domain/navigation/index.js @@ -92,12 +92,14 @@ function pushRightPanelSegment(array, segment) { array.push(new Segment(segment)); } -export function addPanelIfNeeded(navigation, panel, path) { - const segment = navigation.path.get(panel); +export function addPanelIfNeeded(navigation, path) { + const segments = navigation.path.segments; + const i = segments.findIndex(segment => segment.type === "right-panel"); let _path = path; - if (segment?.value) { - _path = _path.with(navigation.segment("right-panel")); - _path = _path.with(segment) + if (i !== -1) { + _path = path.until("room"); + _path = _path.with(segments[i]); + _path = _path.with(segments[i + 1]); } return _path; } diff --git a/src/domain/session/RoomGridViewModel.js b/src/domain/session/RoomGridViewModel.js index a193d48b..08887f3e 100644 --- a/src/domain/session/RoomGridViewModel.js +++ b/src/domain/session/RoomGridViewModel.js @@ -82,8 +82,7 @@ export class RoomGridViewModel extends ViewModel { _switchToRoom(roomId) { let path = this.navigation.path.until("rooms"); path = path.with(this.navigation.segment("room", roomId)); - path = addPanelIfNeeded(this.navigation, "details", path); - path = addPanelIfNeeded(this.navigation, "members", path); + path = addPanelIfNeeded(this.navigation, path); this.navigation.applyPath(path); } diff --git a/src/domain/session/leftpanel/LeftPanelViewModel.js b/src/domain/session/leftpanel/LeftPanelViewModel.js index 549adf6a..9cdb099b 100644 --- a/src/domain/session/leftpanel/LeftPanelViewModel.js +++ b/src/domain/session/leftpanel/LeftPanelViewModel.js @@ -95,8 +95,7 @@ export class LeftPanelViewModel extends ViewModel { _pathForRightPanel(path) { let _path = path; - _path = addPanelIfNeeded(this.navigation, "details", _path); - _path = addPanelIfNeeded(this.navigation, "members", _path); + _path = addPanelIfNeeded(this.navigation, _path); return _path; }