From 59443e6602cbefdabdf601dd48d5eec1fd0709db Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 27 Aug 2020 10:07:47 +0200 Subject: [PATCH] close the room tile view model as well when closing a room so it does not stay selected --- src/domain/session/SessionViewModel.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/domain/session/SessionViewModel.js b/src/domain/session/SessionViewModel.js index 879c5e26..152b77ac 100644 --- a/src/domain/session/SessionViewModel.js +++ b/src/domain/session/SessionViewModel.js @@ -57,24 +57,20 @@ export class SessionViewModel extends ViewModel { } _closeCurrentRoom() { - if (this._currentRoomViewModel) { - this._currentRoomViewModel = this.disposeTracked(this._currentRoomViewModel); - this.emitChange("currentRoom"); - } + this._currentRoomTileViewModel?.close(); + this._currentRoomViewModel = this.disposeTracked(this._currentRoomViewModel); } _openRoom(room, roomTileVM) { - if (this._currentRoomTileViewModel) { - this._currentRoomTileViewModel.close(); - } + this._closeCurrentRoom(); this._currentRoomTileViewModel = roomTileVM; - if (this._currentRoomViewModel) { - this._currentRoomViewModel = this.disposeTracked(this._currentRoomViewModel); - } this._currentRoomViewModel = this.track(new RoomViewModel(this.childOptions({ room, ownUserId: this._session.user.id, - closeCallback: () => this._closeCurrentRoom(), + closeCallback: () => { + this._closeCurrentRoom(); + this.emitChange("currentRoom"); + }, }))); this._currentRoomViewModel.load(); this.emitChange("currentRoom");