mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
fix memory leak when switching room ids
This commit is contained in:
parent
9679058081
commit
3acb3bb48c
@ -36,6 +36,7 @@ This is also why there is an explicit initialize method, see comment there.
|
||||
export class RoomViewModelObservable extends ObservableValue {
|
||||
constructor(sessionViewModel, roomId) {
|
||||
super(null);
|
||||
this._statusSubscription = null;
|
||||
this._sessionViewModel = sessionViewModel;
|
||||
this.id = roomId;
|
||||
}
|
||||
@ -48,9 +49,9 @@ export class RoomViewModelObservable extends ObservableValue {
|
||||
*/
|
||||
async initialize() {
|
||||
const {session} = this._sessionViewModel._sessionContainer;
|
||||
this._statusObservable = await session.observeRoomStatus(this.id);
|
||||
this.set(await this._statusToViewModel(this._statusObservable.get()));
|
||||
this._statusObservable.subscribe(async status => {
|
||||
const statusObservable = await session.observeRoomStatus(this.id);
|
||||
this.set(await this._statusToViewModel(statusObservable.get()));
|
||||
this._statusSubscription = statusObservable.subscribe(async status => {
|
||||
// first dispose existing VM, if any
|
||||
this.get()?.dispose();
|
||||
this.set(await this._statusToViewModel(status));
|
||||
|
Loading…
Reference in New Issue
Block a user