Fix markRead when messages have not been loaded yet

Query the database and not just the in-memory messages.

// FREEBIE
This commit is contained in:
lilia 2016-02-26 12:35:02 -08:00
parent 01053335ac
commit b77d5df4f2

View file

@ -210,18 +210,18 @@
conversationId: conversationId
}));
var readReceipts = this.messageCollection.where({
type: 'incoming', unread: 1
}).map(function(m) {
this.getUnread().then(function(unreadMessages) {
var read = unreadMessages.map(function(m) {
m.markRead();
return {
sender : m.get('source'),
timestamp : m.get('sent_at')
};
}.bind(this));
if (readReceipts.length > 0) {
textsecure.messaging.sendReadReceipts(readReceipts);
});
if (read.length > 0) {
textsecure.messaging.sendReadReceipts(read);
}
});
}
},