From 499783d6979642e9dcd3982d1d508a793363e1b6 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 15 Sep 2016 00:43:30 +0100 Subject: [PATCH] hide room settings when you launch scalar if you haven't made changes --- src/components/views/rooms/RoomSettings.js | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index fc212cce98..105ec2acfb 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -132,11 +132,11 @@ module.exports = React.createClass({ }); return stateWasSetDefer.promise.then(() => { - return this._save(); + return q.allSettled(this._calcSavePromises()); }); }, - _save: function() { + _calcSavePromises: function() { const roomId = this.props.room.roomId; var promises = this.saveAliases(); // returns Promise[] var originalState = this.getInitialState(); @@ -217,16 +217,26 @@ module.exports = React.createClass({ } // color scheme - promises.push(this.saveColor()); + var p; + p = this.saveColor(); + if (!q.isFulfilled(p)) { + promises.push(p); + } // url preview settings - promises.push(this.saveUrlPreviewSettings()); + var ps = this.saveUrlPreviewSettings(); + if (ps.length > 0) { + promises.push(); + } // encryption - promises.push(this.saveEncryption()); + p = this.saveEncryption(); + if (!q.isFulfilled(p)) { + promises.push(p); + } console.log("Performing %s operations: %s", promises.length, JSON.stringify(promises)); - return q.allSettled(promises); + return promises; }, saveAliases: function() { @@ -402,6 +412,9 @@ module.exports = React.createClass({ onManageIntegrations(ev) { ev.preventDefault(); var IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); + if (this._calcSavePromises().length === 0) { + this.props.onCancelClick(ev); + } Modal.createDialog(IntegrationsManager, { src: this.scalarClient.hasCredentials() ? this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : @@ -661,8 +674,8 @@ module.exports = React.createClass({ console.error("Unable to contact integrations server"); } else { integrationsButton = ( -
- +
+ Manage Integrations
); }