forked from mystiq/hydrogen-web
Make navigation changes in one go
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
97e484b8e6
commit
4f05d9a5b7
1 changed files with 12 additions and 5 deletions
|
@ -78,17 +78,23 @@ export class RoomGridViewModel extends ViewModel {
|
||||||
return this._height;
|
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) {
|
focusTile(index) {
|
||||||
if (index === this._selectedIndex) {
|
if (index === this._selectedIndex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const vmo = this._viewModelsObservables[index];
|
const vmo = this._viewModelsObservables[index];
|
||||||
if (vmo) {
|
if (vmo) {
|
||||||
const detailsShown = !!this.navigation.path.get("details")?.value;
|
this._switchToRoom(vmo.id);
|
||||||
this.navigation.push("room", vmo.id);
|
|
||||||
if (detailsShown) {
|
|
||||||
this.navigation.push("details", true);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.navigation.push("empty-grid-tile", index);
|
this.navigation.push("empty-grid-tile", index);
|
||||||
}
|
}
|
||||||
|
@ -183,6 +189,7 @@ export class RoomGridViewModel extends ViewModel {
|
||||||
|
|
||||||
import {createNavigation} from "../navigation/index.js";
|
import {createNavigation} from "../navigation/index.js";
|
||||||
import {ObservableValue} from "../../observable/ObservableValue.js";
|
import {ObservableValue} from "../../observable/ObservableValue.js";
|
||||||
|
import { Segment } from "../navigation/Navigation.js";
|
||||||
|
|
||||||
export function tests() {
|
export function tests() {
|
||||||
class RoomVMMock {
|
class RoomVMMock {
|
||||||
|
|
Loading…
Reference in a new issue