Remove expired message if it expired during database fetch (#1983)
* Log SyncMessage destination, even if it's a group * Remove disappearing message even if deleted during fetch This change fixes a potential race condition with disappearing message removal from the UI. If the UI is in the middle of making a database request for messages to display, then we need to wait for that to complete before removing the newly-deleted expired message.
This commit is contained in:
parent
b2a3a0e679
commit
fb2ebddaa3
2 changed files with 23 additions and 3 deletions
|
@ -645,8 +645,24 @@
|
|||
}
|
||||
},
|
||||
onExpiredCollection: function(message) {
|
||||
console.log('removing message', message.get('sent_at'), 'from collection');
|
||||
this.model.messageCollection.remove(message.id);
|
||||
var removeMessage = function() {
|
||||
console.log(
|
||||
'removing message',
|
||||
message.get('sent_at'),
|
||||
'from collection'
|
||||
);
|
||||
this.model.messageCollection.remove(message.id);
|
||||
}.bind(this);
|
||||
|
||||
// If a fetch is in progress, then we need to wait until that's complete to
|
||||
// do this removal. Otherwise we could remove from messageCollection, then
|
||||
// the async database fetch could include the removed message.
|
||||
|
||||
if (this.inProgressFetch) {
|
||||
this.inProgressFetch.then(removeMessage);
|
||||
} else {
|
||||
removeMessage();
|
||||
}
|
||||
},
|
||||
|
||||
addMessage: function(message) {
|
||||
|
|
|
@ -595,8 +595,12 @@ MessageReceiver.prototype.extend({
|
|||
}
|
||||
if (syncMessage.sent) {
|
||||
var sentMessage = syncMessage.sent;
|
||||
var to = sentMessage.message.group
|
||||
? 'group(' + sentMessage.message.group.id.toBinary() + ')'
|
||||
: sentMessage.destination;
|
||||
|
||||
console.log('sent message to',
|
||||
sentMessage.destination,
|
||||
to,
|
||||
sentMessage.timestamp.toNumber(),
|
||||
'from',
|
||||
this.getEnvelopeId(envelope)
|
||||
|
|
Loading…
Add table
Reference in a new issue