Revert "Merge pull request #2348 from matrix-org/bwindels/roomgridview-experimental"
This reverts commitece5cb1fcc, reversing changes made to64a3d2521c.
This commit is contained in:
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import OpenRoomsStore from './stores/OpenRoomsStore';
|
||||
import RoomViewStore from './stores/RoomViewStore';
|
||||
|
||||
/**
|
||||
* Consumes changes from the OpenRoomsStore and notifies specific things
|
||||
* Consumes changes from the RoomViewStore and notifies specific things
|
||||
* about when the active room changes. Unlike listening for RoomViewStore
|
||||
* changes, you can subscribe to only changes relevant to a particular
|
||||
* room.
|
||||
@@ -28,15 +28,11 @@ import OpenRoomsStore from './stores/OpenRoomsStore';
|
||||
class ActiveRoomObserver {
|
||||
constructor() {
|
||||
this._listeners = {};
|
||||
const roomStore = OpenRoomsStore.getActiveRoomStore();
|
||||
this._activeRoomId = roomStore && roomStore.getRoomId();
|
||||
|
||||
this._activeRoomId = RoomViewStore.getRoomId();
|
||||
// TODO: We could self-destruct when the last listener goes away, or at least
|
||||
// stop listening.
|
||||
this._roomStoreToken = OpenRoomsStore.addListener(this._onOpenRoomsStoreUpdate.bind(this));
|
||||
}
|
||||
|
||||
getActiveRoomId() {
|
||||
return this._activeRoomId;
|
||||
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate.bind(this));
|
||||
}
|
||||
|
||||
addListener(roomId, listener) {
|
||||
@@ -55,23 +51,23 @@ class ActiveRoomObserver {
|
||||
}
|
||||
}
|
||||
|
||||
_emit(roomId, newActiveRoomId) {
|
||||
_emit(roomId) {
|
||||
if (!this._listeners[roomId]) return;
|
||||
|
||||
for (const l of this._listeners[roomId]) {
|
||||
l.call(l, newActiveRoomId);
|
||||
l.call();
|
||||
}
|
||||
}
|
||||
|
||||
_onOpenRoomsStoreUpdate() {
|
||||
const activeRoomStore = OpenRoomsStore.getActiveRoomStore();
|
||||
const newActiveRoomId = activeRoomStore && activeRoomStore.getRoomId();
|
||||
_onRoomViewStoreUpdate() {
|
||||
// emit for the old room ID
|
||||
if (this._activeRoomId) this._emit(this._activeRoomId, newActiveRoomId);
|
||||
if (this._activeRoomId) this._emit(this._activeRoomId);
|
||||
|
||||
// update our cache
|
||||
this._activeRoomId = newActiveRoomId;
|
||||
this._activeRoomId = RoomViewStore.getRoomId();
|
||||
|
||||
// and emit for the new one
|
||||
if (this._activeRoomId) this._emit(this._activeRoomId, this._activeRoomId);
|
||||
if (this._activeRoomId) this._emit(this._activeRoomId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user