@@ -56,15 +56,13 @@ export class PushWorker {
56
56
if ( results . length == 0 ) {
57
57
return ;
58
58
}
59
- return this . sendToAdapter ( body , results , pushStatus , config ) ;
59
+ return this . sendToAdapter ( body , results , pushStatus , config , UTCOffset ) ;
60
60
} , err => {
61
61
throw err ;
62
- } ) . then ( ( results ) => {
63
- return pushStatus . trackSent ( results , UTCOffset ) ;
64
62
} ) ;
65
63
}
66
64
67
- sendToAdapter ( body : any , installations : any [ ] , pushStatus : any , config : Config ) : Promise < * > {
65
+ sendToAdapter ( body : any , installations : any [ ] , pushStatus : any , config : Config , UTCOffset : ? any ) : Promise < * > {
68
66
pushStatus = pushStatusHandler ( config , pushStatus . objectId ) ;
69
67
// Check if we have locales in the push body
70
68
const locales = utils . getLocalesFromPush ( body ) ;
@@ -77,14 +75,16 @@ export class PushWorker {
77
75
const promises = Object . keys ( grouppedInstallations ) . map ( ( locale ) => {
78
76
const installations = grouppedInstallations [ locale ] ;
79
77
const body = bodiesPerLocales [ locale ] ;
80
- return this . sendToAdapter ( body , installations , pushStatus , config ) ;
78
+ return this . sendToAdapter ( body , installations , pushStatus , config , UTCOffset ) ;
81
79
} ) ;
82
80
return Promise . all ( promises ) ;
83
81
}
84
82
85
83
if ( ! utils . isPushIncrementing ( body ) ) {
86
84
logger . verbose ( `Sending push to ${ installations . length } ` ) ;
87
- return this . adapter . send ( body , installations , pushStatus . objectId ) ;
85
+ return this . adapter . send ( body , installations , pushStatus . objectId ) . then ( ( results ) => {
86
+ return pushStatus . trackSent ( results , UTCOffset ) . then ( ( ) => results ) ;
87
+ } ) ;
88
88
}
89
89
90
90
// Collect the badges to reduce the # of calls
@@ -95,7 +95,7 @@ export class PushWorker {
95
95
const payload = deepcopy ( body ) ;
96
96
payload . data . badge = parseInt ( badge ) ;
97
97
const installations = badgeInstallationsMap [ badge ] ;
98
- return this . sendToAdapter ( payload , installations , pushStatus , config ) ;
98
+ return this . sendToAdapter ( payload , installations , pushStatus , config , UTCOffset ) ;
99
99
} ) ;
100
100
return Promise . all ( promises ) ;
101
101
}
0 commit comments