Handle newly added rooms and removed rooms.

This commit is contained in:
lukebarnard 2018-01-05 12:33:26 +00:00
parent 7606e60188
commit 8ade357349

View file

@ -92,9 +92,9 @@ module.exports = React.createClass({
this._visibleRoomsForGroup = { this._visibleRoomsForGroup = {
// $groupId: [$roomId1, $roomId2, ...], // $groupId: [$roomId1, $roomId2, ...],
}; };
// All rooms that should be kept in the room list when filtering // All rooms that should be kept in the room list when filtering.
// By default, set to `null` meaning "all rooms visible" // By default, show all rooms.
this._visibleRooms = null; this._visibleRooms = MatrixClientPeg.get().getRooms();
// When the selected tags are changed, initialise a group store if necessary // When the selected tags are changed, initialise a group store if necessary
this._tagStoreToken = TagOrderStore.addListener(() => { this._tagStoreToken = TagOrderStore.addListener(() => {
TagOrderStore.getSelectedTags().forEach((tag) => { TagOrderStore.getSelectedTags().forEach((tag) => {
@ -197,11 +197,11 @@ module.exports = React.createClass({
}, },
onRoom: function(room) { onRoom: function(room) {
this._delayedRefreshRoomList(); this.updateVisibleRooms();
}, },
onDeleteRoom: function(roomId) { onDeleteRoom: function(roomId) {
this._delayedRefreshRoomList(); this.updateVisibleRooms();
}, },
onArchivedHeaderClick: function(isHidden, scrollToPosition) { onArchivedHeaderClick: function(isHidden, scrollToPosition) {
@ -321,7 +321,7 @@ module.exports = React.createClass({
this._visibleRooms = Array.from(roomSet); this._visibleRooms = Array.from(roomSet);
} else { } else {
// Show all rooms // Show all rooms
this._visibleRooms = null; this._visibleRooms = MatrixClientPeg.get().getRooms();
} }
this.setState({ this.setState({
@ -360,7 +360,7 @@ module.exports = React.createClass({
const dmRoomMap = DMRoomMap.shared(); const dmRoomMap = DMRoomMap.shared();
(this._visibleRooms || MatrixClientPeg.get().getRooms()).forEach((room, index) => { this._visibleRooms.forEach((room, index) => {
const me = room.getMember(MatrixClientPeg.get().credentials.userId); const me = room.getMember(MatrixClientPeg.get().credentials.userId);
if (!me) return; if (!me) return;