@ -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. Conversation Collection( ) ;
var groups = new Group Collection( ) ;
Promise . all ( [
Promise . all ( [
groups . fetchGroups ( receipt . get ( 'source' ) ) ,
groups . fetchGroups ( receipt . get ( 'source' ) ) ,
messages . fetchSentAt ( receipt . get ( 'timestamp' ) )
messages . fetchSentAt ( receipt . get ( 'timestamp' ) )