From 5c37c3d6ce14df5b13093f9c73d892676935fe34 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 19 Nov 2015 16:50:14 -0800 Subject: [PATCH] Change return type from sending messages Pass the whole result from the outgoing message callback on to the caller, and preserve the names of the members. // FREEBIE --- js/libtextsecure.js | 14 +++++++------- js/models/messages.js | 2 +- libtextsecure/outgoing_message.js | 2 +- libtextsecure/sendmessage.js | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 125285de8d04..cac599ffe07d 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -37110,7 +37110,7 @@ OutgoingMessage.prototype = { numberCompleted: function() { this.numbersCompleted++; if (this.numbersCompleted >= this.numbers.length) { - this.callback({success: this.successfulNumbers, failure: this.errors}); + this.callback({successfulNumbers: this.successfulNumbers, errors: this.errors}); } }, registerError: function(number, reason, error) { @@ -37326,10 +37326,10 @@ MessageSender.prototype = { sendIndividualProto: function(number, proto, timestamp) { return new Promise(function(resolve, reject) { this.sendMessageProto(timestamp, [number], proto, function(res) { - if (res.failure.length > 0) - reject(res.failure); + if (res.errors.length > 0) + reject(res); else - resolve(); + resolve(res); }); }.bind(this)); }, @@ -37393,10 +37393,10 @@ MessageSender.prototype = { return new Promise(function(resolve, reject) { this.sendMessageProto(timestamp, numbers, proto, function(res) { - if (res.failure.length > 0) - reject(res.failure); + if (res.errors.length > 0) + reject(res); else - resolve(); + resolve(res); }); }.bind(this)).then(this.sendSyncMessage.bind(this, proto, timestamp)); }, diff --git a/js/models/messages.js b/js/models/messages.js index a65a641db8cb..5f4cb12ae63f 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -146,7 +146,7 @@ }.bind(this)).catch(function(errors) { this.trigger('done'); this.set({sent: true}); - this.saveErrors(errors); + this.saveErrors(result.errors); }.bind(this)); }, diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index c5596ba0cd49..51230af0bf8c 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -19,7 +19,7 @@ OutgoingMessage.prototype = { numberCompleted: function() { this.numbersCompleted++; if (this.numbersCompleted >= this.numbers.length) { - this.callback({success: this.successfulNumbers, failure: this.errors}); + this.callback({successfulNumbers: this.successfulNumbers, errors: this.errors}); } }, registerError: function(number, reason, error) { diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 2b96e4ead9bb..68ea349a73a0 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -58,10 +58,10 @@ MessageSender.prototype = { sendIndividualProto: function(number, proto, timestamp) { return new Promise(function(resolve, reject) { this.sendMessageProto(timestamp, [number], proto, function(res) { - if (res.failure.length > 0) - reject(res.failure); + if (res.errors.length > 0) + reject(res); else - resolve(); + resolve(res); }); }.bind(this)); }, @@ -125,10 +125,10 @@ MessageSender.prototype = { return new Promise(function(resolve, reject) { this.sendMessageProto(timestamp, numbers, proto, function(res) { - if (res.failure.length > 0) - reject(res.failure); + if (res.errors.length > 0) + reject(res); else - resolve(); + resolve(res); }); }.bind(this)).then(this.sendSyncMessage.bind(this, proto, timestamp)); },