From 39289e57ac46b401a95bff3e53c7addfed3b761d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 22 Nov 2018 19:06:58 +0000 Subject: [PATCH] fix correct room being highlighted in left panel --- src/ActiveRoomObserver.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ActiveRoomObserver.js b/src/ActiveRoomObserver.js index f3850dd87c..c276cccb5d 100644 --- a/src/ActiveRoomObserver.js +++ b/src/ActiveRoomObserver.js @@ -55,24 +55,23 @@ class ActiveRoomObserver { } } - _emit(roomId) { + _emit(roomId, newActiveRoomId) { if (!this._listeners[roomId]) return; for (const l of this._listeners[roomId]) { - l.call(); + l.call(l, newActiveRoomId); } } _onOpenRoomsStoreUpdate() { - // emit for the old room ID - if (this._activeRoomId) this._emit(this._activeRoomId); - const activeRoomStore = OpenRoomsStore.getActiveRoomStore(); + const newActiveRoomId = activeRoomStore && activeRoomStore.getRoomId(); + // emit for the old room ID + if (this._activeRoomId) this._emit(this._activeRoomId, newActiveRoomId); // update our cache - this._activeRoomId = activeRoomStore && activeRoomStore.getRoomId(); - + this._activeRoomId = newActiveRoomId; // and emit for the new one - if (this._activeRoomId) this._emit(this._activeRoomId); + if (this._activeRoomId) this._emit(this._activeRoomId, this._activeRoomId); } }