Fix "Delete Messages" not deleting all messages

Since the introduction of infinite scroll, the delete messages function
has only deleted the currently loaded set of messages in a conversation.
To fix this, we should fetch all the messages and then delete them.

Fixes #645

// FREEBIE
This commit is contained in:
lilia 2016-01-27 12:42:27 -08:00
parent 26df196aba
commit 137b992f87

View file

@ -218,10 +218,19 @@
},
destroyMessages: function() {
var models = this.messageCollection.models;
this.messageCollection.reset([]);
_.each(models, function(message) { message.destroy(); });
this.save({active_at: null, lastMessage: ''}); // archive
this.messageCollection.fetch({
index: {
// 'conversation' index on [conversationId, received_at]
name : 'conversation',
lower : [this.id],
upper : [this.id, Number.MAX_VALUE],
}
}).then(function() {
var models = this.messageCollection.models;
this.messageCollection.reset([]);
_.each(models, function(message) { message.destroy(); });
this.save({active_at: null, lastMessage: ''}); // archive
}.bind(this));
},
getTitle: function() {