mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Add join vm to session vm
This commit is contained in:
parent
c27dd97c5e
commit
84920622e3
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user