From 4f05d9a5b76063767ed82a5dec83fee745eb21df Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 15 Jun 2021 14:34:26 +0530 Subject: [PATCH] Make navigation changes in one go Signed-off-by: RMidhunSuresh --- src/domain/session/RoomGridViewModel.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/domain/session/RoomGridViewModel.js b/src/domain/session/RoomGridViewModel.js index c2608680..6dbc5ea4 100644 --- a/src/domain/session/RoomGridViewModel.js +++ b/src/domain/session/RoomGridViewModel.js @@ -78,17 +78,23 @@ export class RoomGridViewModel extends ViewModel { return this._height; } + _switchToRoom(roomId) { + const detailsShown = !!this.navigation.path.get("details")?.value; + let path = this.navigation.path.until("rooms"); + path = path.with(new Segment("room", roomId)); + if (detailsShown) { + path = path.with(new Segment("details", true)); + } + this.navigation.applyPath(path); + } + focusTile(index) { if (index === this._selectedIndex) { return; } const vmo = this._viewModelsObservables[index]; if (vmo) { - const detailsShown = !!this.navigation.path.get("details")?.value; - this.navigation.push("room", vmo.id); - if (detailsShown) { - this.navigation.push("details", true); - } + this._switchToRoom(vmo.id); } else { this.navigation.push("empty-grid-tile", index); } @@ -183,6 +189,7 @@ export class RoomGridViewModel extends ViewModel { import {createNavigation} from "../navigation/index.js"; import {ObservableValue} from "../../observable/ObservableValue.js"; +import { Segment } from "../navigation/Navigation.js"; export function tests() { class RoomVMMock {