From 0475bcd9de0875e83b62fe2eb2306c3d4ac85163 Mon Sep 17 00:00:00 2001 From: manuroe Date: Wed, 13 Jan 2016 17:10:26 +0100 Subject: [PATCH] PushRules settings: BF when changing state of the keywords rule with such a sequence: on -> off -> loud. --- .../views/settings/Notifications.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/views/settings/Notifications.js b/src/components/views/settings/Notifications.js index 3cad6c16b..ce1706100 100644 --- a/src/components/views/settings/Notifications.js +++ b/src/components/views/settings/Notifications.js @@ -117,9 +117,9 @@ module.exports = React.createClass({ } if (actions) { - // Note that the workaound in _updatePushRuleActions will automatically + // Note that the workaround in _updatePushRuleActions will automatically // enable the rule - deferreds.push(this._updatePushRuleActions(rule, actions)); + deferreds.push(this._updatePushRuleActions(rule, actions, enabled)); } else if (enabled != undefined) { deferreds.push(cli.setPushRuleEnabled('global', rule.kind, rule.rule_id, enabled)); @@ -472,7 +472,7 @@ module.exports = React.createClass({ }); }, - _updatePushRuleActions: function(rule, actions) { + _updatePushRuleActions: function(rule, actions, enabled) { // Workaround for SYN-590 : Push rule update fails // Remove the rule and recreate it with the new actions var cli = MatrixClientPeg.get(); @@ -483,7 +483,18 @@ module.exports = React.createClass({ actions: actions, pattern: rule.pattern }).done(function() { - deferred.resolve(); + + // Then, if requested, enabled or disabled the rule + if (undefined != enabled) { + cli.setPushRuleEnabled('global', rule.kind, rule.rule_id, enabled).done(function() { + deferred.resolve(); + }, function(err) { + deferred.reject(err); + }); + } + else { + deferred.resolve(); + } }, function(err) { deferred.reject(err); });