Reduce load from delivery receipt processing
Add a special type of collection just for retrieving group ids, which doesn't incur the overhead of initializing a conversation model along with all its group members.
This commit is contained in:
parent
0854b19371
commit
a8468dae28
1 changed files with 18 additions and 1 deletions
|
@ -4,6 +4,23 @@
|
||||||
;(function() {
|
;(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
window.Whisper = window.Whisper || {};
|
window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
|
var GroupCollection = Backbone.Collection.extend({
|
||||||
|
database: Whisper.Database,
|
||||||
|
storeName: 'conversations',
|
||||||
|
model: Backbone.Model,
|
||||||
|
fetchGroups: function(number) {
|
||||||
|
return new Promise(function(resolve) {
|
||||||
|
this.fetch({
|
||||||
|
index: {
|
||||||
|
name: 'group',
|
||||||
|
only: number
|
||||||
|
}
|
||||||
|
}).always(resolve);
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Whisper.DeliveryReceipts = new (Backbone.Collection.extend({
|
Whisper.DeliveryReceipts = new (Backbone.Collection.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.on('add', this.onReceipt);
|
this.on('add', this.onReceipt);
|
||||||
|
@ -24,7 +41,7 @@
|
||||||
},
|
},
|
||||||
onReceipt: function(receipt) {
|
onReceipt: function(receipt) {
|
||||||
var messages = new Whisper.MessageCollection();
|
var messages = new Whisper.MessageCollection();
|
||||||
var groups = new Whisper.ConversationCollection();
|
var groups = new GroupCollection();
|
||||||
Promise.all([
|
Promise.all([
|
||||||
groups.fetchGroups(receipt.get('source')),
|
groups.fetchGroups(receipt.get('source')),
|
||||||
messages.fetchSentAt(receipt.get('timestamp'))
|
messages.fetchSentAt(receipt.get('timestamp'))
|
||||||
|
|
Loading…
Reference in a new issue