Serialize requests for keys

Fixes #383

// FREEBIE
This commit is contained in:
lilia 2015-11-02 11:32:23 -08:00
parent 4e2723a751
commit 2b9d039837
2 changed files with 14 additions and 8 deletions

View file

@ -39757,11 +39757,14 @@ OutgoingMessage.prototype = {
if (updateDevices === undefined) {
return this.server.getKeysForNumber(number).then(handleResult);
} else {
var promises = updateDevices.map(function(device) {
return this.server.getKeysForNumber(number, device).then(handleResult);
}.bind(this));
var promise = Promise.resolve();
for (var i in updateDevices) {
promise = promise.then(function() {
return this.server.getKeysForNumber(number, updateDevices[i]).then(handleResult);
}.bind(this));
}
return Promise.all(promises);
return promise;
}
},

View file

@ -68,11 +68,14 @@ OutgoingMessage.prototype = {
if (updateDevices === undefined) {
return this.server.getKeysForNumber(number).then(handleResult);
} else {
var promises = updateDevices.map(function(device) {
return this.server.getKeysForNumber(number, device).then(handleResult);
}.bind(this));
var promise = Promise.resolve();
for (var i in updateDevices) {
promise = promise.then(function() {
return this.server.getKeysForNumber(number, updateDevices[i]).then(handleResult);
}.bind(this));
}
return Promise.all(promises);
return promise;
}
},