mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 13:14:58 +08:00
only save RelatedGroupSettings if it was modified. Otherwise perms issue
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
d3e47fa99d
commit
f5f3c894d7
@ -45,11 +45,14 @@ module.exports = React.createClass({
|
|||||||
return {
|
return {
|
||||||
newGroupsList: this.props.relatedGroupsEvent ?
|
newGroupsList: this.props.relatedGroupsEvent ?
|
||||||
(this.props.relatedGroupsEvent.getContent().groups || []) : [],
|
(this.props.relatedGroupsEvent.getContent().groups || []) : [],
|
||||||
|
hasChanged: false,
|
||||||
newGroupId: null,
|
newGroupId: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
saveSettings: function() {
|
saveSettings: function() {
|
||||||
|
if (!this.state.hasChanged) return Promise.resolve();
|
||||||
|
|
||||||
return this.context.matrixClient.sendStateEvent(
|
return this.context.matrixClient.sendStateEvent(
|
||||||
this.props.roomId,
|
this.props.roomId,
|
||||||
'm.room.related_groups',
|
'm.room.related_groups',
|
||||||
@ -82,6 +85,7 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
newGroupsList: this.state.newGroupsList.concat([groupId]),
|
newGroupsList: this.state.newGroupsList.concat([groupId]),
|
||||||
|
hasChanged: true,
|
||||||
newGroupId: '',
|
newGroupId: '',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -92,13 +96,14 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
newGroupsList: Object.assign(this.state.newGroupsList, {[index]: groupId}),
|
newGroupsList: Object.assign(this.state.newGroupsList, {[index]: groupId}),
|
||||||
|
hasChanged: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onGroupDeleted: function(index) {
|
onGroupDeleted: function(index) {
|
||||||
const newGroupsList = this.state.newGroupsList.slice();
|
const newGroupsList = this.state.newGroupsList.slice();
|
||||||
newGroupsList.splice(index, 1),
|
newGroupsList.splice(index, 1);
|
||||||
this.setState({ newGroupsList });
|
this.setState({ newGroupsList, hasChanged: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user