Merge pull request #1430 from matrix-org/luke/groups-fix-feature-self

Fix ability to feature self in a group summary
This commit is contained in:
Luke Barnard 2017-09-27 14:43:50 +01:00 committed by GitHub
commit 3d30cc3733
2 changed files with 9 additions and 1 deletions

View file

@ -239,6 +239,7 @@ const RoleUserList = React.createClass({
button: _t("Add to summary"), button: _t("Add to summary"),
validAddressTypes: ['mx'], validAddressTypes: ['mx'],
groupId: this.props.groupId, groupId: this.props.groupId,
shouldOmitSelf: false,
onFinished: (success, addrs) => { onFinished: (success, addrs) => {
if (!success) return; if (!success) return;
const errorList = []; const errorList = [];

View file

@ -41,7 +41,11 @@ module.exports = React.createClass({
validAddressTypes: PropTypes.arrayOf(PropTypes.oneOf(addressTypes)), validAddressTypes: PropTypes.arrayOf(PropTypes.oneOf(addressTypes)),
onFinished: PropTypes.func.isRequired, onFinished: PropTypes.func.isRequired,
groupId: PropTypes.string, groupId: PropTypes.string,
// The type of entity to search for. Default: 'user'.
pickerType: PropTypes.oneOf(['user', 'room']), pickerType: PropTypes.oneOf(['user', 'room']),
// Whether the current user should be included in the addresses returned. Only
// applicable when pickerType is `user`. Default: false.
includeSelf: PropTypes.bool,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -50,6 +54,7 @@ module.exports = React.createClass({
focus: true, focus: true,
validAddressTypes: addressTypes, validAddressTypes: addressTypes,
pickerType: 'user', pickerType: 'user',
includeSelf: false,
}; };
}, },
@ -366,7 +371,9 @@ module.exports = React.createClass({
}); });
return; return;
} }
if (result.user_id === MatrixClientPeg.get().credentials.userId) { if (!this.props.includeSelf &&
result.user_id === MatrixClientPeg.get().credentials.userId
) {
return; return;
} }