dispose existing view model when changing status, otherwise we leak!

This commit is contained in:
Bruno Windels 2021-05-11 16:39:33 +02:00
parent 8b8214cd1b
commit a0e3848cf6

View file

@ -51,6 +51,8 @@ export class RoomViewModelObservable extends ObservableValue {
this._statusObservable = await session.observeRoomStatus(this.id);
this.set(await this._statusToViewModel(this._statusObservable.get()));
this._statusObservable.subscribe(async status => {
// first dispose existing VM, if any
this.get()?.dispose();
this.set(await this._statusToViewModel(status));
});
}