From 88a1e34987286a560a14c21fdb08728746324e30 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 14 Jun 2021 21:04:44 +0530 Subject: [PATCH] Unsubscribe on dispose Signed-off-by: RMidhunSuresh --- .../session/rightpanel/RoomDetailsViewModel.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/domain/session/rightpanel/RoomDetailsViewModel.js b/src/domain/session/rightpanel/RoomDetailsViewModel.js index 6430b922..911e5945 100644 --- a/src/domain/session/rightpanel/RoomDetailsViewModel.js +++ b/src/domain/session/rightpanel/RoomDetailsViewModel.js @@ -5,7 +5,8 @@ export class RoomDetailsViewModel extends ViewModel { constructor(options) { super(options); this._room = options.room; - this._room.on("change", () => this.emitChange()); + this._onRoomChange = this._onRoomChange.bind(this); + this._room.on("change", this._onRoomChange); } get roomId() { @@ -44,8 +45,17 @@ export class RoomDetailsViewModel extends ViewModel { return this.name; } + _onRoomChange() { + this.emitChange(); + } + closePanel() { const path = this.navigation.path.until("room"); this.navigation.applyPath(path); } + + dispose() { + super.dispose(); + this._room.off("change", this._onRoomChange); + } }