mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +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 {RoomGridViewModel} from "./RoomGridViewModel.js";
|
||||||
import {SettingsViewModel} from "./settings/SettingsViewModel.js";
|
import {SettingsViewModel} from "./settings/SettingsViewModel.js";
|
||||||
import {CreateRoomViewModel} from "./CreateRoomViewModel.js";
|
import {CreateRoomViewModel} from "./CreateRoomViewModel.js";
|
||||||
|
import {JoinRoomViewModel} from "./JoinRoomViewModel";
|
||||||
import {ViewModel} from "../ViewModel";
|
import {ViewModel} from "../ViewModel";
|
||||||
import {RoomViewModelObservable} from "./RoomViewModelObservable.js";
|
import {RoomViewModelObservable} from "./RoomViewModelObservable.js";
|
||||||
import {RightPanelViewModel} from "./rightpanel/RightPanelViewModel.js";
|
import {RightPanelViewModel} from "./rightpanel/RightPanelViewModel.js";
|
||||||
@ -45,6 +46,7 @@ export class SessionViewModel extends ViewModel {
|
|||||||
this._roomViewModelObservable = null;
|
this._roomViewModelObservable = null;
|
||||||
this._gridViewModel = null;
|
this._gridViewModel = null;
|
||||||
this._createRoomViewModel = null;
|
this._createRoomViewModel = null;
|
||||||
|
this._joinRoomViewModel = null;
|
||||||
this._setupNavigation();
|
this._setupNavigation();
|
||||||
this._setupForcedLogoutOnAccessTokenInvalidation();
|
this._setupForcedLogoutOnAccessTokenInvalidation();
|
||||||
}
|
}
|
||||||
@ -83,6 +85,12 @@ export class SessionViewModel extends ViewModel {
|
|||||||
}));
|
}));
|
||||||
this._updateCreateRoom(createRoom.get());
|
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");
|
const lightbox = this.navigation.observe("lightbox");
|
||||||
this.track(lightbox.subscribe(eventId => {
|
this.track(lightbox.subscribe(eventId => {
|
||||||
this._updateLightbox(eventId);
|
this._updateLightbox(eventId);
|
||||||
@ -121,7 +129,13 @@ export class SessionViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get activeMiddleViewModel() {
|
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() {
|
get roomGridViewModel() {
|
||||||
@ -152,6 +166,10 @@ export class SessionViewModel extends ViewModel {
|
|||||||
return this._createRoomViewModel;
|
return this._createRoomViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get joinRoomViewModel() {
|
||||||
|
return this._joinRoomViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
_updateGrid(roomIds) {
|
_updateGrid(roomIds) {
|
||||||
const changed = !(this._gridViewModel && roomIds);
|
const changed = !(this._gridViewModel && roomIds);
|
||||||
const currentRoomId = this.navigation.path.get("room");
|
const currentRoomId = this.navigation.path.get("room");
|
||||||
@ -286,6 +304,16 @@ export class SessionViewModel extends ViewModel {
|
|||||||
this.emitChange("activeMiddleViewModel");
|
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) {
|
_updateLightbox(eventId) {
|
||||||
if (this._lightboxViewModel) {
|
if (this._lightboxViewModel) {
|
||||||
this._lightboxViewModel = this.disposeTracked(this._lightboxViewModel);
|
this._lightboxViewModel = this.disposeTracked(this._lightboxViewModel);
|
||||||
|
Loading…
Reference in New Issue
Block a user