Split updatedSelectedTagsRooms

because we don't need to get the rooms for all groups when
the filtered tags change.
This commit is contained in:
Luke Barnard 2017-12-15 14:23:35 +00:00
parent df1134f092
commit 961d5e1868

View file

@ -102,11 +102,12 @@ module.exports = React.createClass({
this._groupStores[tag] = GroupStoreCache.getGroupStore(tag);
this._groupStores[tag].registerListener(() => {
// This group's rooms or members may have updated, update rooms for its tag
this.updateSelectedTagsRooms(dmRoomMap, [tag]);
this.updateSelectedTagsRoomsForGroups(dmRoomMap, tag);
this.updateSelectedTagsRooms();
});
});
// Filters themselves have changed, refresh the selected tags
this.updateSelectedTagsRooms(dmRoomMap, FilterStore.getSelectedTags());
this.updateSelectedTagsRooms();
});
this.refreshRoomList();
@ -269,9 +270,8 @@ module.exports = React.createClass({
}, 500),
// Update which rooms and users should appear in RoomList as dictated by selected tags
updateSelectedTagsRooms: function(dmRoomMap, updatedTags) {
updateSelectedTagsRoomsForGroups: function(dmRoomMap, tag) {
if (!this.mounted) return;
updatedTags.forEach((tag) => {
// For now, only handle group tags
const store = this._groupStores[tag];
if (!store) return;
@ -285,8 +285,9 @@ module.exports = React.createClass({
);
});
// TODO: Check if room has been tagged to the group by the user
});
},
updateSelectedTagsRooms: function() {
this._selectedTagsRoomIds = [];
FilterStore.getSelectedTags().forEach((tag) => {
(this._selectedTagsRoomIdsForGroup[tag] || []).forEach(