From 3bbff627fc1a4ae01246466fb51aa5578308cab4 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 17 Oct 2017 17:26:34 +0100 Subject: [PATCH 1/3] Fix bug preventing partial group profile When updating the group profile, send empty strings instead of `null` as synapse does not expect `null`. --- src/components/structures/GroupView.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index c9cc375563..cba50a9ef4 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -524,8 +524,15 @@ export default React.createClass({ }, _onSaveClick: function() { + const newGroupProfile = this.state.profileForm; + // Synapse is not expecting `null`, so map unset values to the empty string + Object.keys(newGroupProfile).forEach((k) => { + if (!newGroupProfile[k]) { + newGroupProfile[k] = ''; + } + }); this.setState({saving: true}); - MatrixClientPeg.get().setGroupProfile(this.props.groupId, this.state.profileForm).then((result) => { + MatrixClientPeg.get().setGroupProfile(this.props.groupId, newGroupProfile).then((result) => { this.setState({ saving: false, editing: false, From 1b8c5b50db450777fc57557fa2741d880807f0db Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 17 Oct 2017 18:02:35 +0100 Subject: [PATCH 2/3] Don't show room IDs when picking rooms --- src/components/views/dialogs/AddressPickerDialog.js | 8 +++++++- src/components/views/elements/AddressSelector.js | 10 +++++++++- src/components/views/elements/AddressTile.js | 5 ++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 2637f9d466..8c6f033bdc 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -489,7 +489,12 @@ module.exports = React.createClass({ const AddressTile = sdk.getComponent("elements.AddressTile"); for (let i = 0; i < this.state.userList.length; i++) { query.push( - , + , ); } } @@ -539,6 +544,7 @@ module.exports = React.createClass({ addressSelector = ( {this.addressSelector = ref;}} addressList={this.state.queryList} + showAddress={this.props.pickerType === 'user'} onSelected={this.onSelected} truncateAt={TRUNCATE_QUERY_LIST} /> diff --git a/src/components/views/elements/AddressSelector.js b/src/components/views/elements/AddressSelector.js index 9a8cd34867..9330206a39 100644 --- a/src/components/views/elements/AddressSelector.js +++ b/src/components/views/elements/AddressSelector.js @@ -30,6 +30,8 @@ export default React.createClass({ // List of the addresses to display addressList: React.PropTypes.arrayOf(UserAddressType).isRequired, + // Whether to show the address on the address tiles + showAddress: React.PropTypes.bool, truncateAt: React.PropTypes.number.isRequired, selected: React.PropTypes.number, @@ -142,7 +144,13 @@ export default React.createClass({ key={this.props.addressList[i].addressType + "/" + this.props.addressList[i].address} ref={(ref) => { this.addressListElement = ref; }} > - + , ); } diff --git a/src/components/views/elements/AddressTile.js b/src/components/views/elements/AddressTile.js index a61cbbc794..c8ea4062b1 100644 --- a/src/components/views/elements/AddressTile.js +++ b/src/components/views/elements/AddressTile.js @@ -87,7 +87,10 @@ export default React.createClass({ info = (
{ name }
-
{ address.address }
+ { this.props.showAddress ? +
{ address.address }
: +
+ }
); } else if (isMatrixAddress) { From df9e037bfccfd588c24a0f6f30c4df87aaa2bb93 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 17 Oct 2017 18:11:00 +0100 Subject: [PATCH 3/3] Default values when GETing instead of when POSTing --- src/components/structures/GroupView.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index cba50a9ef4..7c8ef80b80 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -448,8 +448,16 @@ export default React.createClass({ _initGroupStore: function(groupId) { this._groupStore = GroupStoreCache.getGroupStore(MatrixClientPeg.get(), groupId); this._groupStore.on('update', () => { + const summary = this._groupStore.getSummary(); + if (summary.profile) { + // Default profile fields should be "" for later sending to the server (which + // requires that the fields are strings, not null) + ["avatar_url", "long_description", "name", "short_description"].forEach((k) => { + summary.profile[k] = summary.profile[k] || ""; + }); + } this.setState({ - summary: this._groupStore.getSummary(), + summary, error: null, }); }); @@ -524,15 +532,8 @@ export default React.createClass({ }, _onSaveClick: function() { - const newGroupProfile = this.state.profileForm; - // Synapse is not expecting `null`, so map unset values to the empty string - Object.keys(newGroupProfile).forEach((k) => { - if (!newGroupProfile[k]) { - newGroupProfile[k] = ''; - } - }); this.setState({saving: true}); - MatrixClientPeg.get().setGroupProfile(this.props.groupId, newGroupProfile).then((result) => { + MatrixClientPeg.get().setGroupProfile(this.props.groupId, this.state.profileForm).then((result) => { this.setState({ saving: false, editing: false,