Fix incoming message display/storage
There were a few problems. 1. The message event was being triggered in background, not popup 2. The initial message/thread fetches from localStorage were mis-ordered 3. The timestamp wasn't being extracted from the right place 4. #3 caused messages to fail validation and not be saved 1-3 are fixed. To address 4 I switched validate() to log a warning instead of preventing save.
This commit is contained in:
parent
c90b9a5c59
commit
a09a4776d3
3 changed files with 9 additions and 5 deletions
|
@ -7,7 +7,7 @@ var Whisper = Whisper || {};
|
|||
validate: function(attributes, options) {
|
||||
var required = ['body', 'timestamp', 'threadId'];
|
||||
var missing = _.filter(required, function(attr) { return !attributes[attr]; });
|
||||
if (missing.length) { return "Message must have " + missing; }
|
||||
if (missing.length) { console.log("Message missing attributes: " + missing); }
|
||||
},
|
||||
|
||||
thread: function() {
|
||||
|
@ -33,7 +33,7 @@ var Whisper = Whisper || {};
|
|||
body: decrypted.message.body,
|
||||
attachments: attachments,
|
||||
type: 'incoming',
|
||||
timestamp: decrypted.message.timestamp
|
||||
timestamp: decrypted.pushMessage.timestamp
|
||||
});
|
||||
m.save();
|
||||
|
||||
|
@ -42,7 +42,6 @@ var Whisper = Whisper || {};
|
|||
thread.set('unreadCount', thread.get('unreadCount') + 1);
|
||||
thread.save();
|
||||
}
|
||||
thread.trigger('message', m);
|
||||
return m;
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue