From b87058508ea3748c3c93f519ec8325b9ea7b4d4a Mon Sep 17 00:00:00 2001 From: wmwragg Date: Thu, 28 Jul 2016 15:28:05 +0100 Subject: [PATCH] When a use clicks the state they want, after the change has been made it pasues breifly before closing, so that the user can see their state change has taken place. --- .../NotificationStateContextMenu.js | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/components/views/context_menus/NotificationStateContextMenu.js b/src/components/views/context_menus/NotificationStateContextMenu.js index 869145aa..8f3152d2 100644 --- a/src/components/views/context_menus/NotificationStateContextMenu.js +++ b/src/components/views/context_menus/NotificationStateContextMenu.js @@ -48,20 +48,27 @@ module.exports = React.createClass({ }, _save: function( isMuted ) { + var self = this; const roomId = this.props.room.roomId; - /* - if (this.state.areNotifsMuted !== originalState.areNotifsMuted) { - promises.push(MatrixClientPeg.get().setRoomMutePushRule( - "global", roomId, this.state.areNotifsMuted - )); - } - */ var cli = MatrixClientPeg.get(); - this.setState({areNotifsMuted: isMuted}); + if (!cli.isGuest()) { cli.setRoomMutePushRule( "global", roomId, isMuted - ); + ).then(function() { + console.log("DEBUG: then"); + self.setState({areNotifsMuted: isMuted}); + + // delay slightly so that the user can see their state change + q.delay(500).then(function() { + if (self.props.onFinished) { + self.props.onFinished(); + }; + }); + }).fail(function(error) { + console.log("DEBUG: fail"); + console.log(error); + }); } }, @@ -71,9 +78,6 @@ module.exports = React.createClass({ _onClickAllNotifs: function() { this._save(false); - if (this.props.onFinished) { - this.props.onFinished(); - }; }, _onClickMentions: function() { @@ -82,9 +86,6 @@ module.exports = React.createClass({ _onClickMute: function() { this._save(true); - if (this.props.onFinished) { - this.props.onFinished(); - }; }, render: function() {