From e9949152bbe55cd2940534ca8143b6316087a39b Mon Sep 17 00:00:00 2001 From: lilia Date: Fri, 27 Nov 2015 16:29:38 -0800 Subject: [PATCH] Always return a promise from sendSyncMessage // FREEBIE --- js/libtextsecure.js | 28 +++++++++++++++------------- libtextsecure/sendmessage.js | 28 +++++++++++++++------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 6699788d568..4f7113cbe01 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -37404,20 +37404,22 @@ MessageSender.prototype = { sendSyncMessage: function(encodedDataMessage, timestamp, destination) { var myNumber = textsecure.storage.user.getNumber(); var myDevice = textsecure.storage.user.getDeviceId(); - if (myDevice != 1) { - var dataMessage = textsecure.protobuf.DataMessage.decode(encodedDataMessage); - var sentMessage = new textsecure.protobuf.SyncMessage.Sent(); - sentMessage.timestamp = timestamp; - sentMessage.message = dataMessage; - if (destination) { - sentMessage.destination = destination; - } - var syncMessage = new textsecure.protobuf.SyncMessage(); - syncMessage.sent = sentMessage; - var contentMessage = new textsecure.protobuf.Content(); - contentMessage.syncMessage = syncMessage; - return this.sendIndividualProto(myNumber, contentMessage, Date.now()); + if (myDevice == 1) { + return Promise.resolve(); } + + var dataMessage = textsecure.protobuf.DataMessage.decode(encodedDataMessage); + var sentMessage = new textsecure.protobuf.SyncMessage.Sent(); + sentMessage.timestamp = timestamp; + sentMessage.message = dataMessage; + if (destination) { + sentMessage.destination = destination; + } + var syncMessage = new textsecure.protobuf.SyncMessage(); + syncMessage.sent = sentMessage; + var contentMessage = new textsecure.protobuf.Content(); + contentMessage.syncMessage = syncMessage; + return this.sendIndividualProto(myNumber, contentMessage, Date.now()); }, sendRequestGroupSyncMessage: function() { diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index f3dcb1bcba5..22a3c6b14b4 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -69,20 +69,22 @@ MessageSender.prototype = { sendSyncMessage: function(encodedDataMessage, timestamp, destination) { var myNumber = textsecure.storage.user.getNumber(); var myDevice = textsecure.storage.user.getDeviceId(); - if (myDevice != 1) { - var dataMessage = textsecure.protobuf.DataMessage.decode(encodedDataMessage); - var sentMessage = new textsecure.protobuf.SyncMessage.Sent(); - sentMessage.timestamp = timestamp; - sentMessage.message = dataMessage; - if (destination) { - sentMessage.destination = destination; - } - var syncMessage = new textsecure.protobuf.SyncMessage(); - syncMessage.sent = sentMessage; - var contentMessage = new textsecure.protobuf.Content(); - contentMessage.syncMessage = syncMessage; - return this.sendIndividualProto(myNumber, contentMessage, Date.now()); + if (myDevice == 1) { + return Promise.resolve(); } + + var dataMessage = textsecure.protobuf.DataMessage.decode(encodedDataMessage); + var sentMessage = new textsecure.protobuf.SyncMessage.Sent(); + sentMessage.timestamp = timestamp; + sentMessage.message = dataMessage; + if (destination) { + sentMessage.destination = destination; + } + var syncMessage = new textsecure.protobuf.SyncMessage(); + syncMessage.sent = sentMessage; + var contentMessage = new textsecure.protobuf.Content(); + contentMessage.syncMessage = syncMessage; + return this.sendIndividualProto(myNumber, contentMessage, Date.now()); }, sendRequestGroupSyncMessage: function() {