Handle groups being joined and left

pull/21833/head
Luke Barnard 2017-12-11 18:03:19 +00:00
parent 8d2d3e62cd
commit a120335130
2 changed files with 20 additions and 2 deletions

View File

@ -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) => {

View File

@ -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;
}