fix correct room being highlighted in left panel

pull/21833/head
Bruno Windels 2018-11-22 19:06:58 +00:00
parent 1810c17d24
commit 39289e57ac
1 changed files with 7 additions and 8 deletions

View File

@ -55,24 +55,23 @@ class ActiveRoomObserver {
} }
} }
_emit(roomId) { _emit(roomId, newActiveRoomId) {
if (!this._listeners[roomId]) return; if (!this._listeners[roomId]) return;
for (const l of this._listeners[roomId]) { for (const l of this._listeners[roomId]) {
l.call(); l.call(l, newActiveRoomId);
} }
} }
_onOpenRoomsStoreUpdate() { _onOpenRoomsStoreUpdate() {
// emit for the old room ID
if (this._activeRoomId) this._emit(this._activeRoomId);
const activeRoomStore = OpenRoomsStore.getActiveRoomStore(); 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 // update our cache
this._activeRoomId = activeRoomStore && activeRoomStore.getRoomId(); this._activeRoomId = newActiveRoomId;
// and emit for the new one // and emit for the new one
if (this._activeRoomId) this._emit(this._activeRoomId); if (this._activeRoomId) this._emit(this._activeRoomId, this._activeRoomId);
} }
} }