Only create one group store listener in RoomList
Instead of creating several and destroying the reference to the one created before.
This commit is contained in:
parent
e3a07be127
commit
4d8394954c
2 changed files with 17 additions and 12 deletions
|
@ -91,19 +91,22 @@ module.exports = React.createClass({
|
||||||
// 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, show all rooms.
|
// By default, show all rooms.
|
||||||
this._visibleRooms = MatrixClientPeg.get().getRooms();
|
this._visibleRooms = MatrixClientPeg.get().getRooms();
|
||||||
// When the selected tags are changed, initialise a group store if necessary
|
|
||||||
this._tagStoreToken = TagOrderStore.addListener(() => {
|
// Listen to updates to group data. RoomList cares about members and rooms in order
|
||||||
|
// to filter the room list when group tags are selected.
|
||||||
|
this._groupStoreToken = GroupStore.registerListener(null, () => {
|
||||||
(TagOrderStore.getOrderedTags() || []).forEach((tag) => {
|
(TagOrderStore.getOrderedTags() || []).forEach((tag) => {
|
||||||
if (tag[0] !== '+') {
|
if (tag[0] !== '+') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._groupStoreToken = GroupStore.registerListener(tag, () => {
|
|
||||||
// This group's rooms or members may have updated, update rooms for its tag
|
// This group's rooms or members may have updated, update rooms for its tag
|
||||||
this.updateVisibleRoomsForTag(dmRoomMap, tag);
|
this.updateVisibleRoomsForTag(dmRoomMap, tag);
|
||||||
this.updateVisibleRooms();
|
this.updateVisibleRooms();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// Filters themselves have changed, refresh the selected tags
|
|
||||||
|
this._tagStoreToken = TagOrderStore.addListener(() => {
|
||||||
|
// Filters themselves have changed
|
||||||
this.updateVisibleRooms();
|
this.updateVisibleRooms();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -183,10 +183,12 @@ class GroupStore extends EventEmitter {
|
||||||
// Call to set initial state (before fetching starts)
|
// Call to set initial state (before fetching starts)
|
||||||
this.emit('update');
|
this.emit('update');
|
||||||
|
|
||||||
|
if (groupId) {
|
||||||
this._fetchResource(this.STATE_KEY.Summary, groupId);
|
this._fetchResource(this.STATE_KEY.Summary, groupId);
|
||||||
this._fetchResource(this.STATE_KEY.GroupRooms, groupId);
|
this._fetchResource(this.STATE_KEY.GroupRooms, groupId);
|
||||||
this._fetchResource(this.STATE_KEY.GroupMembers, groupId);
|
this._fetchResource(this.STATE_KEY.GroupMembers, groupId);
|
||||||
this._fetchResource(this.STATE_KEY.GroupInvitedMembers, groupId);
|
this._fetchResource(this.STATE_KEY.GroupInvitedMembers, groupId);
|
||||||
|
}
|
||||||
|
|
||||||
// Similar to the Store of flux/utils, we return a "token" that
|
// Similar to the Store of flux/utils, we return a "token" that
|
||||||
// can be used to unregister the listener.
|
// can be used to unregister the listener.
|
||||||
|
|
Loading…
Reference in a new issue