You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Replace yet more deferreds
This commit is contained in:
@@ -3870,7 +3870,7 @@ MatrixClient.prototype.setRoomMutePushRule = function(scope, roomId, mute) {
|
|||||||
} else if (!hasDontNotifyRule) {
|
} else if (!hasDontNotifyRule) {
|
||||||
// Remove the existing one before setting the mute push rule
|
// Remove the existing one before setting the mute push rule
|
||||||
// This is a workaround to SYN-590 (Push rule update fails)
|
// This is a workaround to SYN-590 (Push rule update fails)
|
||||||
deferred = Promise.defer();
|
deferred = utils.defer();
|
||||||
this.deletePushRule(scope, "room", roomPushRule.rule_id)
|
this.deletePushRule(scope, "room", roomPushRule.rule_id)
|
||||||
.done(function() {
|
.done(function() {
|
||||||
self.addPushRule(scope, "room", roomId, {
|
self.addPushRule(scope, "room", roomId, {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
|
|
||||||
import Promise from 'bluebird';
|
import Promise from 'bluebird';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
|
import {defer} from '../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An IndexedDB store backend where the actual backend sits in a web
|
* An IndexedDB store backend where the actual backend sits in a web
|
||||||
@@ -152,7 +153,7 @@ RemoteIndexedDBStoreBackend.prototype = {
|
|||||||
// the promise automatically gets rejected
|
// the promise automatically gets rejected
|
||||||
return Promise.resolve().then(() => {
|
return Promise.resolve().then(() => {
|
||||||
const seq = this._nextSeq++;
|
const seq = this._nextSeq++;
|
||||||
const def = Promise.defer();
|
const def = defer();
|
||||||
|
|
||||||
this._inFlight[seq] = def;
|
this._inFlight[seq] = def;
|
||||||
|
|
||||||
|
|||||||
13
src/utils.js
13
src/utils.js
@@ -714,3 +714,16 @@ module.exports.ensureNoTrailingSlash = function(url) {
|
|||||||
module.exports.sleep = (ms, value) => new Promise((resolve => {
|
module.exports.sleep = (ms, value) => new Promise((resolve => {
|
||||||
setTimeout(resolve, ms, value);
|
setTimeout(resolve, ms, value);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Returns a Deferred
|
||||||
|
module.exports.defer = () => {
|
||||||
|
let resolve;
|
||||||
|
let reject;
|
||||||
|
|
||||||
|
const promise = new Promise((_resolve, _reject) => {
|
||||||
|
resolve = _resolve;
|
||||||
|
reject = _reject;
|
||||||
|
});
|
||||||
|
|
||||||
|
return {resolve, reject, promise};
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user