dispose existing view model when changing status, otherwise we leak!
This commit is contained in:
parent
8b8214cd1b
commit
a0e3848cf6
1 changed files with 2 additions and 0 deletions
|
@ -51,6 +51,8 @@ export class RoomViewModelObservable extends ObservableValue {
|
||||||
this._statusObservable = await session.observeRoomStatus(this.id);
|
this._statusObservable = await session.observeRoomStatus(this.id);
|
||||||
this.set(await this._statusToViewModel(this._statusObservable.get()));
|
this.set(await this._statusToViewModel(this._statusObservable.get()));
|
||||||
this._statusObservable.subscribe(async status => {
|
this._statusObservable.subscribe(async status => {
|
||||||
|
// first dispose existing VM, if any
|
||||||
|
this.get()?.dispose();
|
||||||
this.set(await this._statusToViewModel(status));
|
this.set(await this._statusToViewModel(status));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue