fix memory leak when switching room ids
This commit is contained in:
parent
9679058081
commit
3acb3bb48c
1 changed files with 4 additions and 3 deletions
|
@ -36,6 +36,7 @@ This is also why there is an explicit initialize method, see comment there.
|
||||||
export class RoomViewModelObservable extends ObservableValue {
|
export class RoomViewModelObservable extends ObservableValue {
|
||||||
constructor(sessionViewModel, roomId) {
|
constructor(sessionViewModel, roomId) {
|
||||||
super(null);
|
super(null);
|
||||||
|
this._statusSubscription = null;
|
||||||
this._sessionViewModel = sessionViewModel;
|
this._sessionViewModel = sessionViewModel;
|
||||||
this.id = roomId;
|
this.id = roomId;
|
||||||
}
|
}
|
||||||
|
@ -48,9 +49,9 @@ export class RoomViewModelObservable extends ObservableValue {
|
||||||
*/
|
*/
|
||||||
async initialize() {
|
async initialize() {
|
||||||
const {session} = this._sessionViewModel._sessionContainer;
|
const {session} = this._sessionViewModel._sessionContainer;
|
||||||
this._statusObservable = await session.observeRoomStatus(this.id);
|
const statusObservable = await session.observeRoomStatus(this.id);
|
||||||
this.set(await this._statusToViewModel(this._statusObservable.get()));
|
this.set(await this._statusToViewModel(statusObservable.get()));
|
||||||
this._statusObservable.subscribe(async status => {
|
this._statusSubscription = statusObservable.subscribe(async status => {
|
||||||
// first dispose existing VM, if any
|
// first dispose existing VM, if any
|
||||||
this.get()?.dispose();
|
this.get()?.dispose();
|
||||||
this.set(await this._statusToViewModel(status));
|
this.set(await this._statusToViewModel(status));
|
||||||
|
|
Reference in a new issue