diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 4016a9adcb4c..7eb70d366a66 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -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; } }, diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index b2b32edab23f..16af122d7433 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -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; } },