From be82547ea1d83642900076609c40faee2c7e96b9 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 18 May 2014 19:50:08 -0400 Subject: [PATCH] Move message saving out of helpers.js --- js/background.js | 1 + js/helpers.js | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/js/background.js b/js/background.js index 06e38db5e..edf069d98 100644 --- a/js/background.js +++ b/js/background.js @@ -21,6 +21,7 @@ textsecure.registerOnLoadFunction(function() { } else { if (isRegistrationDone()) { textsecure.subscribeToPush(function(message) { + Whisper.Messages.addIncomingMessage(message); console.log("Got message from " + message.pushMessage.source + "." + message.pushMessage.sourceDevice + ': "' + getString(message.message.body) + '"'); var newUnreadCount = storage.getUnencrypted("unreadCount", 0) + 1; diff --git a/js/helpers.js b/js/helpers.js index a704499a4..aa9762c91 100644 --- a/js/helpers.js +++ b/js/helpers.js @@ -469,13 +469,9 @@ window.textsecure.subscribeToPush = function() { }; var promises = []; - for (var i = 0; i < decrypted.message.attachments.length; i++) { + for (var i = 0; i < decrypted.message.attachments.length; i++) promises[i] = handleAttachment(decrypted.message.attachments[i]); - } - return Promise.all(promises).then(function() { - Whisper.Messages.addIncomingMessage(decrypted); - message_callback(decrypted); - }); + return Promise.all(promises).then(message_callback); }) }).catch(function(e) { console.log("Error handling incoming message: ");