diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js
index d902309571..b0194fda9a 100644
--- a/src/components/structures/GroupView.js
+++ b/src/components/structures/GroupView.js
@@ -179,10 +179,12 @@ export default React.createClass({
summary: null,
error: null,
editing: false,
+ saving: false,
};
},
componentWillMount: function() {
+ this._changeAvatarComponent = null;
this._loadGroupFromServer(this.props.groupId);
},
@@ -197,6 +199,10 @@ export default React.createClass({
}
},
+ _collectChangeAvatar: function(node) {
+ this._changeAvatarComponent = node;
+ },
+
_loadGroupFromServer: function(groupId) {
MatrixClientPeg.get().getGroupSummary(groupId).done((res) => {
this.setState({
@@ -246,8 +252,36 @@ export default React.createClass({
});
},
+ _onAvatarSelected: function(e) {
+ },
+
+ _onAvatarChange: function(newAvatarUrl) {
+ const newProfileForm = Object.assign(this.state.profileForm, { avatar_url: newAvatarUrl });
+ this.setState({
+ profileForm: newProfileForm,
+ });
+ },
+
_onSaveClick: function() {
- // TODO: There's no API to edit group profile info yet.
+ this.setState({saving: true});
+ MatrixClientPeg.get().setGroupProfile(this.props.groupId, this.state.profileForm).then((result) => {
+ this.setState({
+ saving: false,
+ editing: false,
+ summary: false,
+ });
+ return this._loadGroupFromServer(this.props.groupId);
+ }).catch((e) => {
+ this.setState({
+ saving: false,
+ });
+ const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
+ console.error("Failed to save group profile", e);
+ Modal.createDialog(ErrorDialog, {
+ title: _t('Error'),
+ description: _t('Failed to update group'),
+ });
+ }).done();
},
_getFeaturedRoomsNode() {
@@ -330,8 +364,9 @@ export default React.createClass({
const GroupAvatar = sdk.getComponent("avatars.GroupAvatar");
const Loader = sdk.getComponent("elements.Spinner");
const ChangeAvatar = sdk.getComponent("settings.ChangeAvatar");
+ const TintableSvg = sdk.getComponent("elements.TintableSvg");
- if (this.state.summary === null && this.state.error === null) {
+ if (this.state.summary === null && this.state.error === null || this.state.saving) {
return