From 84920622e302e3d71a69e80e113e18d63e0d0e8c Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 12 Sep 2022 17:18:57 +0530 Subject: [PATCH] Add join vm to session vm --- src/domain/session/SessionViewModel.js | 30 +++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/domain/session/SessionViewModel.js b/src/domain/session/SessionViewModel.js index 7226dbdf..ecb2b759 100644 --- a/src/domain/session/SessionViewModel.js +++ b/src/domain/session/SessionViewModel.js @@ -25,6 +25,7 @@ import {SessionStatusViewModel} from "./SessionStatusViewModel.js"; import {RoomGridViewModel} from "./RoomGridViewModel.js"; import {SettingsViewModel} from "./settings/SettingsViewModel.js"; import {CreateRoomViewModel} from "./CreateRoomViewModel.js"; +import {JoinRoomViewModel} from "./JoinRoomViewModel"; import {ViewModel} from "../ViewModel"; import {RoomViewModelObservable} from "./RoomViewModelObservable.js"; import {RightPanelViewModel} from "./rightpanel/RightPanelViewModel.js"; @@ -45,6 +46,7 @@ export class SessionViewModel extends ViewModel { this._roomViewModelObservable = null; this._gridViewModel = null; this._createRoomViewModel = null; + this._joinRoomViewModel = null; this._setupNavigation(); this._setupForcedLogoutOnAccessTokenInvalidation(); } @@ -83,6 +85,12 @@ export class SessionViewModel extends ViewModel { })); this._updateCreateRoom(createRoom.get()); + const joinRoom = this.navigation.observe("join-room"); + this.track(joinRoom.subscribe((joinRoomOpen) => { + this._updateJoinRoom(joinRoomOpen); + })); + this._updateJoinRoom(joinRoom.get()); + const lightbox = this.navigation.observe("lightbox"); this.track(lightbox.subscribe(eventId => { this._updateLightbox(eventId); @@ -121,7 +129,13 @@ export class SessionViewModel extends ViewModel { } get activeMiddleViewModel() { - return this._roomViewModelObservable?.get() || this._gridViewModel || this._settingsViewModel || this._createRoomViewModel; + return ( + this._roomViewModelObservable?.get() || + this._gridViewModel || + this._settingsViewModel || + this._createRoomViewModel || + this._joinRoomViewModel + ); } get roomGridViewModel() { @@ -152,6 +166,10 @@ export class SessionViewModel extends ViewModel { return this._createRoomViewModel; } + get joinRoomViewModel() { + return this._joinRoomViewModel; + } + _updateGrid(roomIds) { const changed = !(this._gridViewModel && roomIds); const currentRoomId = this.navigation.path.get("room"); @@ -286,6 +304,16 @@ export class SessionViewModel extends ViewModel { this.emitChange("activeMiddleViewModel"); } + _updateJoinRoom(joinRoomOpen) { + if (this._joinRoomViewModel) { + this._joinRoomViewModel = this.disposeTracked(this._joinRoomViewModel); + } + if (joinRoomOpen) { + this._joinRoomViewModel = this.track(new JoinRoomViewModel(this.childOptions({session: this._client.session}))); + } + this.emitChange("activeMiddleViewModel"); + } + _updateLightbox(eventId) { if (this._lightboxViewModel) { this._lightboxViewModel = this.disposeTracked(this._lightboxViewModel);