only save RelatedGroupSettings if it was modified. Otherwise perms issue

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2018-01-04 14:24:13 +00:00
parent d3e47fa99d
commit f5f3c894d7
No known key found for this signature in database
GPG Key ID: 0435A1D4BBD34D64
1 changed files with 7 additions and 2 deletions

View File

@ -45,11 +45,14 @@ module.exports = React.createClass({
return {
newGroupsList: this.props.relatedGroupsEvent ?
(this.props.relatedGroupsEvent.getContent().groups || []) : [],
hasChanged: false,
newGroupId: null,
};
},
saveSettings: function() {
if (!this.state.hasChanged) return Promise.resolve();
return this.context.matrixClient.sendStateEvent(
this.props.roomId,
'm.room.related_groups',
@ -82,6 +85,7 @@ module.exports = React.createClass({
}
this.setState({
newGroupsList: this.state.newGroupsList.concat([groupId]),
hasChanged: true,
newGroupId: '',
});
},
@ -92,13 +96,14 @@ module.exports = React.createClass({
}
this.setState({
newGroupsList: Object.assign(this.state.newGroupsList, {[index]: groupId}),
hasChanged: true,
});
},
onGroupDeleted: function(index) {
const newGroupsList = this.state.newGroupsList.slice();
newGroupsList.splice(index, 1),
this.setState({ newGroupsList });
newGroupsList.splice(index, 1);
this.setState({ newGroupsList, hasChanged: true });
},
render: function() {