From 426d0779ee68677679783b3e4f3aef9a5628c3d9 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 31 May 2021 22:14:43 +0530 Subject: [PATCH] Keep RoomInfoView open across room/grid changes Signed-off-by: RMidhunSuresh --- src/domain/navigation/index.js | 3 +++ src/domain/session/RoomGridViewModel.js | 16 ++++++++++------ src/domain/session/SessionViewModel.js | 3 +-- .../session/leftpanel/LeftPanelViewModel.js | 3 +++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/domain/navigation/index.js b/src/domain/navigation/index.js index 2dab6f0c..5e1a1b62 100644 --- a/src/domain/navigation/index.js +++ b/src/domain/navigation/index.js @@ -113,6 +113,9 @@ export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) { segments.push(roomsSegmentWithRoom(rooms, roomId, currentNavPath)); } segments.push(new Segment("room", roomId)); + if (currentNavPath.get("details")?.value) { + segments.push(new Segment("details")); + } } else if (type === "last-session") { let sessionSegment = currentNavPath.get("session"); if (typeof sessionSegment?.value !== "string" && defaultSessionId) { diff --git a/src/domain/session/RoomGridViewModel.js b/src/domain/session/RoomGridViewModel.js index aee80b6a..8fce26ad 100644 --- a/src/domain/session/RoomGridViewModel.js +++ b/src/domain/session/RoomGridViewModel.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {ViewModel} from "../ViewModel.js"; +import { ViewModel } from "../ViewModel.js"; function dedupeSparse(roomIds) { return roomIds.map((id, idx) => { @@ -84,7 +84,11 @@ export class RoomGridViewModel extends ViewModel { } const vmo = this._viewModelsObservables[index]; if (vmo) { + const detailsShown = !!this.navigation.path.get("details"); this.navigation.push("room", vmo.id); + if (detailsShown) { + this.navigation.push("details", true); + } } else { this.navigation.push("empty-grid-tile", index); } @@ -146,7 +150,7 @@ export class RoomGridViewModel extends ViewModel { this.emitChange(); viewModel?.focus(); } - + /** called from SessionViewModel */ releaseRoomViewModel(roomId) { const index = this._viewModelsObservables.findIndex(vmo => vmo && vmo.id === roomId); @@ -177,10 +181,10 @@ export class RoomGridViewModel extends ViewModel { } } -import {createNavigation} from "../navigation/index.js"; -import {ObservableValue} from "../../observable/ObservableValue.js"; +import { createNavigation } from "../navigation/index.js"; +import { ObservableValue } from "../../observable/ObservableValue.js"; -export function tests() { +export function tests() { class RoomVMMock { constructor(id) { this.id = id; @@ -196,7 +200,7 @@ export function tests() { } class RoomViewModelObservableMock extends ObservableValue { - async initialize() {} + async initialize() { } dispose() { this.get()?.dispose(); } get id() { return this.get()?.id; } } diff --git a/src/domain/session/SessionViewModel.js b/src/domain/session/SessionViewModel.js index a570e14f..1ad5d50e 100644 --- a/src/domain/session/SessionViewModel.js +++ b/src/domain/session/SessionViewModel.js @@ -63,6 +63,7 @@ export class SessionViewModel extends ViewModel { if (!this._gridViewModel) { this._updateRoom(roomId); } + this._toggleRoomInformationPanel(); })); if (!this._gridViewModel) { this._updateRoom(currentRoomId.get()); @@ -125,8 +126,6 @@ export class SessionViewModel extends ViewModel { _updateGrid(roomIds) { const changed = !(this._gridViewModel && roomIds); const currentRoomId = this.navigation.path.get("room"); - // Close right-panel if needed - this._toggleRoomInformationPanel(); if (roomIds) { if (!this._gridViewModel) { this._gridViewModel = this.track(new RoomGridViewModel(this.childOptions({ diff --git a/src/domain/session/leftpanel/LeftPanelViewModel.js b/src/domain/session/leftpanel/LeftPanelViewModel.js index 6503c124..96becf2a 100644 --- a/src/domain/session/leftpanel/LeftPanelViewModel.js +++ b/src/domain/session/leftpanel/LeftPanelViewModel.js @@ -93,11 +93,13 @@ export class LeftPanelViewModel extends ViewModel { } toggleGrid() { + const details = this.navigation.path.get("details"); if (this.gridEnabled) { let path = this.navigation.path.until("session"); const room = this.navigation.path.get("room"); if (room) { path = path.with(room); + path = path.with(details); } this.navigation.applyPath(path); } else { @@ -106,6 +108,7 @@ export class LeftPanelViewModel extends ViewModel { if (room) { path = path.with(this.navigation.segment("rooms", [room.value])); path = path.with(room); + path = path.with(details); } else { path = path.with(this.navigation.segment("rooms", [])); path = path.with(this.navigation.segment("empty-grid-tile", 0));