Factor out _getDisplayeDGroups
This commit is contained in:
parent
b748c62880
commit
b32e4a57bc
1 changed files with 15 additions and 8 deletions
|
@ -83,6 +83,18 @@ export default React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getDisplayedGroups(userGroups, relatedGroups) {
|
||||||
|
let displayedGroups = userGroups || [];
|
||||||
|
if (relatedGroups && relatedGroups.length > 0) {
|
||||||
|
displayedGroups = displayedGroups.filter((groupId) => {
|
||||||
|
return relatedGroups.includes(groupId);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
displayedGroups = [];
|
||||||
|
}
|
||||||
|
return displayedGroups;
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const EmojiText = sdk.getComponent('elements.EmojiText');
|
const EmojiText = sdk.getComponent('elements.EmojiText');
|
||||||
const {mxEvent} = this.props;
|
const {mxEvent} = this.props;
|
||||||
|
@ -93,14 +105,9 @@ export default React.createClass({
|
||||||
return <span />; // emote message must include the name so don't duplicate it
|
return <span />; // emote message must include the name so don't duplicate it
|
||||||
}
|
}
|
||||||
|
|
||||||
let displayedGroups = this.state.userGroups || [];
|
const displayedGroups = this._getDisplayedGroups(
|
||||||
if (this.state.relatedGroups && this.state.relatedGroups.length > 0) {
|
this.state.userGroups, this.state.relatedGroups,
|
||||||
displayedGroups = displayedGroups.filter((groupId) => {
|
);
|
||||||
return this.state.relatedGroups.includes(groupId);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
displayedGroups = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
name = displayedGroups.length > 0 ? name.replace(' (IRC)', '') : name;
|
name = displayedGroups.length > 0 ? name.replace(' (IRC)', '') : name;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue