Handle groups being joined and left
parent
8d2d3e62cd
commit
a120335130
|
@ -60,6 +60,7 @@ const TagPanel = React.createClass({
|
|||
|
||||
const orderedTags = TagOrderStore.getOrderedTags() || [];
|
||||
const orderedGroupTags = orderedTags.filter((t) => t[0] === '+');
|
||||
// XXX: One profile lookup failing will bring the whole lot down
|
||||
Promise.all(orderedGroupTags.map(
|
||||
(groupId) => FlairStore.getGroupProfileCached(this.context.matrixClient, groupId),
|
||||
)).then((orderedGroupTagProfiles) => {
|
||||
|
|
|
@ -97,11 +97,28 @@ class TagOrderStore extends Store {
|
|||
|
||||
_updateOrderedTags() {
|
||||
this._setState({
|
||||
orderedTags: this._state.hasSynced && this._state.hasFetchedJoinedGroups ?
|
||||
this._state.orderedTagsAccountData || this._state.joinedGroupIds : null,
|
||||
orderedTags:
|
||||
this._state.hasSynced &&
|
||||
this._state.hasFetchedJoinedGroups ?
|
||||
this._mergeGroupsAndTags() : null,
|
||||
});
|
||||
}
|
||||
|
||||
_mergeGroupsAndTags() {
|
||||
const groupIds = this._state.joinedGroupIds || [];
|
||||
const tags = this._state.orderedTagsAccountData || [];
|
||||
|
||||
const tagsToKeep = tags.filter(
|
||||
(t) => t[0] !== '+' || groupIds.includes(t),
|
||||
);
|
||||
|
||||
const groupIdsToAdd = groupIds.filter(
|
||||
(groupId) => !tags.includes(groupId),
|
||||
);
|
||||
|
||||
return tagsToKeep.concat(groupIdsToAdd);
|
||||
}
|
||||
|
||||
getOrderedTags() {
|
||||
return this._state.orderedTags;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue