@@ -5517,7 +5517,7 @@ var qm = {
5517
5517
refreshIfEmpty : function ( successHandler , errorHandler ) {
5518
5518
if ( ! qm . notifications . getNumberInGlobalsOrLocalStorage ( ) ) {
5519
5519
qm . qmLog . info ( 'No notifications in local storage' ) ;
5520
- qm . notifications . refreshNotifications ( successHandler , errorHandler ) ;
5520
+ qm . notifications . post ( successHandler , errorHandler ) ;
5521
5521
return true ;
5522
5522
}
5523
5523
qm . qmLog . info ( qm . notifications . getNumberInGlobalsOrLocalStorage ( ) + ' notifications in local storage' ) ;
@@ -5528,7 +5528,7 @@ var qm = {
5528
5528
qm . qmLog . info ( "qm.notifications.refreshIfEmptyOrStale" ) ;
5529
5529
if ( ! qm . notifications . getNumberInGlobalsOrLocalStorage ( ) || qm . notifications . getSecondsSinceLastNotificationsRefresh ( ) > 3600 ) {
5530
5530
qm . qmLog . info ( 'Refreshing notifications because empty or last refresh was more than an hour ago' ) ;
5531
- qm . notifications . refreshNotifications ( callback ) ;
5531
+ qm . notifications . post ( callback ) ;
5532
5532
} else {
5533
5533
qm . qmLog . info ( 'Not refreshing notifications because last refresh was last than an hour ago and we have notifications in local storage' ) ;
5534
5534
if ( callback ) {
@@ -5620,39 +5620,16 @@ var qm = {
5620
5620
} else {
5621
5621
console . info ( 'No rating notifications for popup' ) ;
5622
5622
qm . notifications . getLastNotificationsRefreshTime ( ) ;
5623
- qm . notifications . refreshNotifications ( ) ;
5623
+ qm . notifications . post ( ) ;
5624
5624
return null ;
5625
5625
}
5626
5626
} ,
5627
5627
deleteByVariableName : function ( variableName ) {
5628
5628
return qm . storage . deleteByProperty ( qm . items . trackingReminderNotifications , 'variableName' , variableName ) ;
5629
5629
} ,
5630
5630
promise : null ,
5631
- refreshNotifications : function ( successHandler , errorHandler , options ) {
5632
- var route = qm . apiPaths . trackingReminderNotificationsPast ;
5633
- qm . api . getRequestUrl ( route , function ( url ) {
5634
- // Can't use QM SDK in service worker
5635
- qm . api . getViaXhrOrFetch ( url , function ( response ) {
5636
- if ( ! response ) {
5637
- qm . qmLog . error ( "No response from " + url ) ;
5638
- if ( errorHandler ) {
5639
- errorHandler ( "No response from " + url ) ;
5640
- }
5641
- return ;
5642
- }
5643
- if ( response . status === 401 ) {
5644
- qm . chrome . showSignInNotification ( ) ;
5645
- } else {
5646
- qm . storage . setTrackingReminderNotifications ( response . data ) ;
5647
- if ( successHandler ) {
5648
- successHandler ( response . data ) ;
5649
- }
5650
- }
5651
- } )
5652
- } , options ) ;
5653
- } ,
5654
5631
refreshAndShowPopupIfNecessary : function ( notificationParams ) {
5655
- qm . notifications . refreshNotifications ( notificationParams , function ( trackingReminderNotifications ) {
5632
+ qm . notifications . post ( function ( response ) {
5656
5633
var uniqueNotification = qm . notifications . getMostRecentUniqueNotificationNotInSyncQueue ( ) ;
5657
5634
function objectLength ( obj ) {
5658
5635
var result = 0 ;
@@ -5664,6 +5641,7 @@ var qm = {
5664
5641
}
5665
5642
return result ;
5666
5643
}
5644
+ var trackingReminderNotifications = qm . notifications . getFromGlobalsOrLocalStorage ( ) ;
5667
5645
var numberOfWaitingNotifications = objectLength ( trackingReminderNotifications ) ;
5668
5646
if ( uniqueNotification ) {
5669
5647
function getChromeRatingNotificationParams ( trackingReminderNotification ) {
@@ -5769,7 +5747,7 @@ var qm = {
5769
5747
if ( ! successHandler ) {
5770
5748
return null ;
5771
5749
}
5772
- qm . notifications . refreshNotifications ( function ( notifications ) {
5750
+ qm . notifications . post ( function ( response ) {
5773
5751
var notification = qm . notifications . getMostRecentNotification ( ) ;
5774
5752
if ( notification ) {
5775
5753
successHandler ( notification ) ;
@@ -5854,6 +5832,7 @@ var qm = {
5854
5832
var measurements = response . measurements ;
5855
5833
if ( ! measurements && response . data ) { measurements = response . data . measurements ; }
5856
5834
if ( measurements ) { qm . measurements . addMeasurementsToMemory ( measurements ) ; }
5835
+ qm . storage . setTrackingReminderNotifications ( response . data . trackingReminderNotifications ) ;
5857
5836
if ( successHandler ) { successHandler ( response ) ; }
5858
5837
} , function ( response ) {
5859
5838
if ( ! response . success ) {
0 commit comments