From 6bc9b32ab7af565150e46805b6d6d13e60167a65 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 27 Sep 2017 11:04:41 +0100 Subject: [PATCH 1/2] Fix ability to feature self in a group summary By default the AddressPicker would omit the currently logged-in user. This adds a property to override that to allow "self" to be picked. --- src/components/structures/GroupView.js | 1 + src/components/views/dialogs/AddressPickerDialog.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index f90ba31653a..9c20f75e469 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -239,6 +239,7 @@ const RoleUserList = React.createClass({ button: _t("Add to summary"), validAddressTypes: ['mx'], groupId: this.props.groupId, + shouldOmitSelf: false, onFinished: (success, addrs) => { if (!success) return; const errorList = []; diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 22cf242fcf6..f168a411f59 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -41,7 +41,11 @@ module.exports = React.createClass({ validAddressTypes: PropTypes.arrayOf(PropTypes.oneOf(addressTypes)), onFinished: PropTypes.func.isRequired, groupId: PropTypes.string, + // The type of entity to search for. Default: 'user'. pickerType: PropTypes.oneOf(['user', 'room']), + // Whether the current user should be omitted from the address returned. Only + // applicable when pickerType is `user`. Default: true. + shouldOmitSelf: PropTypes.bool, }, getDefaultProps: function() { @@ -50,6 +54,7 @@ module.exports = React.createClass({ focus: true, validAddressTypes: addressTypes, pickerType: 'user', + shouldOmitSelf: true, }; }, @@ -366,7 +371,9 @@ module.exports = React.createClass({ }); return; } - if (result.user_id === MatrixClientPeg.get().credentials.userId) { + if (this.props.shouldOmitSelf && + result.user_id === MatrixClientPeg.get().credentials.userId + ) { return; } From e3405cfd9595f0f313a7318c96ee02c1e152bfae Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 27 Sep 2017 11:52:05 +0100 Subject: [PATCH 2/2] shouldOmitSelf -> includeSelf --- src/components/views/dialogs/AddressPickerDialog.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index f168a411f59..73fdf714a57 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -43,9 +43,9 @@ module.exports = React.createClass({ groupId: PropTypes.string, // The type of entity to search for. Default: 'user'. pickerType: PropTypes.oneOf(['user', 'room']), - // Whether the current user should be omitted from the address returned. Only - // applicable when pickerType is `user`. Default: true. - shouldOmitSelf: PropTypes.bool, + // Whether the current user should be included in the addresses returned. Only + // applicable when pickerType is `user`. Default: false. + includeSelf: PropTypes.bool, }, getDefaultProps: function() { @@ -54,7 +54,7 @@ module.exports = React.createClass({ focus: true, validAddressTypes: addressTypes, pickerType: 'user', - shouldOmitSelf: true, + includeSelf: false, }; }, @@ -371,7 +371,7 @@ module.exports = React.createClass({ }); return; } - if (this.props.shouldOmitSelf && + if (!this.props.includeSelf && result.user_id === MatrixClientPeg.get().credentials.userId ) { return;