mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Merge pull request #1171 from vector-im/markjh/cleanup_promise
Use then() chaining rather than manual callbacks
This commit is contained in:
commit
1e0c4d8797
@ -558,19 +558,9 @@ module.exports = React.createClass({
|
|||||||
// Create a push rule but disabled
|
// Create a push rule but disabled
|
||||||
_addDisabledPushRule: function(scope, kind, ruleId, body) {
|
_addDisabledPushRule: function(scope, kind, ruleId, body) {
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
var deferred = q.defer();
|
return cli.addPushRule(scope, kind, ruleId, body).then(function() {
|
||||||
|
return cli.setPushRuleEnabled(scope, kind, ruleId, false);
|
||||||
cli.addPushRule(scope, kind, ruleId, body).done(function() {
|
|
||||||
cli.setPushRuleEnabled(scope, kind, ruleId, false).done(function() {
|
|
||||||
deferred.resolve();
|
|
||||||
}, function(err) {
|
|
||||||
deferred.reject(err);
|
|
||||||
});
|
});
|
||||||
}, function(err) {
|
|
||||||
deferred.reject(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Check if any legacy im.vector rules need to be ported to the new API
|
// Check if any legacy im.vector rules need to be ported to the new API
|
||||||
@ -830,7 +820,6 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
_updatePushRuleActions: function(rule, actions, enabled) {
|
_updatePushRuleActions: function(rule, actions, enabled) {
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
var deferred = q.defer();
|
|
||||||
|
|
||||||
return cli.setPushRuleActions(
|
return cli.setPushRuleActions(
|
||||||
'global', rule.kind, rule.rule_id, actions
|
'global', rule.kind, rule.rule_id, actions
|
||||||
|
Loading…
Reference in New Issue
Block a user