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