mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
cleanup SessionViewModel, use ViewModel dispose infrastructure
This commit is contained in:
parent
3adc609e07
commit
c4b17e4be6
@ -1,12 +1,12 @@
|
||||
import {RoomTileViewModel} from "./roomlist/RoomTileViewModel.js";
|
||||
import {RoomViewModel} from "./room/RoomViewModel.js";
|
||||
import {SyncStatusViewModel} from "./SyncStatusViewModel.js";
|
||||
import {SessionStatusViewModel} from "./SessionStatusViewModel.js";
|
||||
import {ViewModel} from "../ViewModel.js";
|
||||
|
||||
export class SessionViewModel extends ViewModel {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
const sessionContainer = options.sessionContainer;
|
||||
const {sessionContainer} = options;
|
||||
this._session = sessionContainer.session;
|
||||
this._sessionStatusViewModel = this.track(new SessionStatusViewModel(this.childOptions({
|
||||
syncStatus: sessionContainer.sync.status,
|
||||
@ -39,30 +39,22 @@ export class SessionViewModel extends ViewModel {
|
||||
return this._currentRoomViewModel;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
if (this._currentRoomViewModel) {
|
||||
this._currentRoomViewModel.dispose();
|
||||
this._currentRoomViewModel = null;
|
||||
}
|
||||
}
|
||||
|
||||
_closeCurrentRoom() {
|
||||
if (this._currentRoomViewModel) {
|
||||
this._currentRoomViewModel.dispose();
|
||||
this._currentRoomViewModel = null;
|
||||
this._currentRoomViewModel = this.disposeTracked(this._currentRoomViewModel);
|
||||
this.emitChange("currentRoom");
|
||||
}
|
||||
}
|
||||
|
||||
_openRoom(room) {
|
||||
if (this._currentRoomViewModel) {
|
||||
this._currentRoomViewModel.dispose();
|
||||
this._currentRoomViewModel = this.disposeTracked(this._currentRoomViewModel);
|
||||
}
|
||||
this._currentRoomViewModel = new RoomViewModel(this.childOptions({
|
||||
this._currentRoomViewModel = this.track(new RoomViewModel(this.childOptions({
|
||||
room,
|
||||
ownUserId: this._session.user.id,
|
||||
closeCallback: () => this._closeCurrentRoom(),
|
||||
}));
|
||||
})));
|
||||
this._currentRoomViewModel.load();
|
||||
this.emitChange("currentRoom");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user