Use read receipt envelope to infer startExpirationTime

Avoids display of phantom messages that are only received and marked
read locally long after they have expired on another linked device.
This commit is contained in:
lilia 2016-09-21 15:06:31 -07:00
parent 96fd017890
commit 02ea4f2475
5 changed files with 25 additions and 14 deletions

View file

@ -254,16 +254,19 @@ MessageReceiver.prototype.extend({
} else if (syncMessage.read) {
console.log('read messages',
'from', envelope.source + '.' + envelope.sourceDevice);
this.handleRead(syncMessage.read);
this.handleRead(syncMessage.read, envelope.timestamp);
} else {
throw new Error('Got empty SyncMessage');
}
},
handleRead: function(read) {
handleRead: function(read, timestamp) {
for (var i = 0; i < read.length; ++i) {
var ev = new Event('read');
ev.timestamp = read[i].timestamp;
ev.sender = read[i].sender;
ev.timestamp = timestamp.toNumber();
ev.read = {
timestamp : read[i].timestamp.toNumber(),
sender : read[i].sender
}
this.dispatchEvent(ev);
}
},