Update to use new join_policy API

pull/21833/head
David Baker 2018-04-05 16:56:35 +01:00
parent c9283ad988
commit 03747b8287
1 changed files with 12 additions and 10 deletions

View File

@ -1,6 +1,6 @@
/* /*
Copyright 2017 Vector Creations Ltd. Copyright 2017 Vector Creations Ltd.
Copyright 2017 New Vector Ltd. Copyright 2017, 2018 New Vector Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -399,8 +399,8 @@ FeaturedRoom.contextTypes = GroupContext;
RoleUserList.contextTypes = GroupContext; RoleUserList.contextTypes = GroupContext;
FeaturedUser.contextTypes = GroupContext; FeaturedUser.contextTypes = GroupContext;
const GROUP_JOINABLE = "GROUP_JOINABLE"; const GROUP_JOINPOLICY_OPEN = "open";
const GROUP_NOT_JOINABLE = "GROUP_NOT_JOINABLE"; const GROUP_JOINPOLICY_INVITE = "invite";
export default React.createClass({ export default React.createClass({
displayName: 'GroupView', displayName: 'GroupView',
@ -549,7 +549,7 @@ export default React.createClass({
editing: true, editing: true,
profileForm: Object.assign({}, this.state.summary.profile), profileForm: Object.assign({}, this.state.summary.profile),
joinableForm: { joinableForm: {
isJoinable: this.state.summary.profile.is_joinable, policyType: this.state.summary.profile.join_policy,
}, },
}); });
dis.dispatch({ dis.dispatch({
@ -615,7 +615,7 @@ export default React.createClass({
_onJoinableChange: function(ev) { _onJoinableChange: function(ev) {
this.setState({ this.setState({
joinableForm: { isJoinable: ev.target.value === GROUP_JOINABLE }, joinableForm: { policyType: ev.target.value },
}); });
}, },
@ -654,7 +654,9 @@ export default React.createClass({
_saveGroup: async function() { _saveGroup: async function() {
await this._matrixClient.setGroupProfile(this.props.groupId, this.state.profileForm); await this._matrixClient.setGroupProfile(this.props.groupId, this.state.profileForm);
await this._matrixClient.setGroupJoinable(this.props.groupId, this.state.joinableForm.isJoinable); await this._matrixClient.setGroupJoinPolicy(this.props.groupId, {
type: this.state.joinableForm.policyType,
});
}, },
_onAcceptInviteClick: function() { _onAcceptInviteClick: function() {
@ -1010,8 +1012,8 @@ export default React.createClass({
<div> <div>
<label> <label>
<input type="radio" <input type="radio"
value={GROUP_NOT_JOINABLE} value={GROUP_JOINPOLICY_INVITE}
checked={!this.state.joinableForm.isJoinable} checked={this.state.joinableForm.policyType === GROUP_JOINPOLICY_INVITE}
onClick={this._onJoinableChange} onClick={this._onJoinableChange}
/> />
<div className="mx_GroupView_label_text"> <div className="mx_GroupView_label_text">
@ -1022,8 +1024,8 @@ export default React.createClass({
<div> <div>
<label> <label>
<input type="radio" <input type="radio"
value={GROUP_JOINABLE} value={GROUP_JOINPOLICY_OPEN}
checked={this.state.joinableForm.isJoinable} checked={this.state.joinableForm.policyType === GROUP_JOINPOLICY_OPEN}
onClick={this._onJoinableChange} onClick={this._onJoinableChange}
/> />
<div className="mx_GroupView_label_text"> <div className="mx_GroupView_label_text">