@@ -60,15 +60,15 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
60
60
} ) ;
61
61
$scope . stateParams = $stateParams ;
62
62
qmService . actionSheet . setDefaultActionSheet ( function ( ) {
63
- $scope . refreshTrackingReminderNotifications ( ) ;
63
+ $scope . syncTrackingReminderNotifications ( ) ;
64
64
} , getVariableCategoryName ( ) ) ;
65
65
qmService . splash . hideSplashScreen ( ) ;
66
66
} ) ;
67
67
$scope . $on ( '$ionicView.afterEnter' , function ( ) {
68
68
qmLog . info ( 'RemindersInboxCtrl afterEnter: ' + window . location . href ) ;
69
69
setPageTitle ( ) ; // Setting title afterEnter doesn't fix cutoff on Android
70
70
if ( needToRefresh ( ) ) {
71
- $scope . refreshTrackingReminderNotifications ( ) ;
71
+ $scope . syncTrackingReminderNotifications ( ) ;
72
72
}
73
73
if ( $rootScope . platform . isWeb ) {
74
74
qm . webNotifications . registerServiceWorker ( ) ;
@@ -77,7 +77,7 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
77
77
} ) ;
78
78
$scope . $on ( '$ionicView.beforeLeave' , function ( ) {
79
79
qmLog . debug ( 'RemindersInboxCtrl beforeLeave' ) ;
80
- qm . notifications . post ( ) ;
80
+ qmService . syncTrackingReminderNotifications ( ) ;
81
81
} ) ;
82
82
$scope . $on ( '$ionicView.afterLeave' , function ( ) {
83
83
qmLog . debug ( 'RemindersInboxCtrl afterLeave' ) ;
@@ -105,12 +105,11 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
105
105
function autoRefresh ( ) {
106
106
$timeout ( function ( ) {
107
107
if ( $state . current . name . toLowerCase ( ) . indexOf ( 'inbox' ) !== - 1 ) {
108
- $scope . refreshTrackingReminderNotifications ( ) ;
108
+ $scope . syncTrackingReminderNotifications ( ) ;
109
109
autoRefresh ( ) ;
110
110
}
111
111
} , 30 * 60 * 1000 ) ;
112
112
}
113
-
114
113
var setPageTitle = function ( ) {
115
114
if ( getVariableCategoryName ( ) === 'Treatments' ) {
116
115
$scope . state . title = 'Overdue Meds' ;
@@ -148,7 +147,7 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
148
147
if ( qm . notifications . getNumberInGlobalsOrLocalStorage ( cat ) ) {
149
148
getTrackingReminderNotifications ( ) ;
150
149
} else {
151
- $scope . refreshTrackingReminderNotifications ( ) ;
150
+ $scope . syncTrackingReminderNotifications ( ) ;
152
151
}
153
152
}
154
153
}
@@ -178,17 +177,6 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
178
177
} ) ;
179
178
}
180
179
}
181
- function refreshNotificationsForCategory ( cat ) {
182
- qmLog . info ( 'Falling back to getTrackingReminderNotificationsFromApi request for category ' + cat ) ;
183
- qmService . refreshTrackingReminderNotifications ( {
184
- variableCategoryName : cat ,
185
- onlyPast : true
186
- } , function ( response ) {
187
- qmLog . info ( 'getTrackingReminderNotificationsFromApi response for ' + cat +
188
- ': ' + JSON . stringify ( response ) ) ;
189
- addNotificationsToScope ( response . data )
190
- } ) ;
191
- }
192
180
function getNumberOfDisplayedNotifications ( ) {
193
181
var total = 0 ;
194
182
var dividers = $scope . notificationDividers ;
@@ -232,15 +220,13 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
232
220
function getFallbackInboxContentIfNecessary ( ) {
233
221
var num = getNumberOfDisplayedNotifications ( ) ;
234
222
if ( ! num && ! $scope . state . loading ) {
235
- var cat = getVariableCategoryName ( ) ;
236
- if ( cat ) { refreshNotificationsForCategory ( cat ) ; }
237
223
getFavorites ( ) ;
238
224
getDiscoveries ( ) ;
239
225
}
240
226
}
241
227
var closeWindowIfNecessary = function ( ) {
242
228
if ( $state . current . name === "app.remindersInboxCompact" && ! getNumberOfDisplayedNotifications ( ) ) {
243
- $scope . refreshTrackingReminderNotifications ( ) ;
229
+ $scope . syncTrackingReminderNotifications ( ) ;
244
230
window . close ( ) ;
245
231
}
246
232
} ;
@@ -432,19 +418,6 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
432
418
logNotificationDividers ( $scope . notificationDividers ) ;
433
419
} )
434
420
}
435
- var getFilteredTodayTrackingReminderNotifications = function ( ) {
436
- qmService . getTodayTrackingReminderNotificationsDeferred ( getVariableCategoryName ( ) )
437
- . then ( function ( trackingReminderNotifications ) {
438
- addNotificationsToScope ( trackingReminderNotifications )
439
- getFallbackInboxContentIfNecessary ( ) ;
440
- hideInboxLoader ( ) ;
441
- } , function ( error ) {
442
- getFallbackInboxContentIfNecessary ( ) ;
443
- qmLog . error ( error ) ;
444
- qmLog . error ( 'failed to get reminder notifications!' ) ;
445
- hideInboxLoader ( ) ;
446
- } ) ;
447
- } ;
448
421
$rootScope . $on ( 'broadcastGetTrackingReminderNotifications' , function ( ) {
449
422
qmLog . info ( 'getTrackingReminderNotifications broadcast received..' ) ;
450
423
getFilteredTrackingReminderNotificationsFromLocalStorage ( ) ;
@@ -465,16 +438,16 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
465
438
}
466
439
} , 10000 ) ;
467
440
} ;
468
- $scope . refreshTrackingReminderNotifications = function ( params ) {
441
+ $scope . syncTrackingReminderNotifications = function ( params ) {
469
442
showLoader ( ) ;
470
- qmService . refreshTrackingReminderNotifications ( params ) . then ( function ( ) {
443
+ qmService . syncTrackingReminderNotifications ( params ) . then ( function ( ) {
471
444
getTrackingReminderNotifications ( ) ;
472
445
if ( ! getNumberOfDisplayedNotifications ( ) ) {
473
446
getFallbackInboxContentIfNecessary ( ) ;
474
447
}
475
448
} , function ( error ) {
476
449
getFallbackInboxContentIfNecessary ( ) ;
477
- qmLog . info ( '$scope.refreshTrackingReminderNotifications : ' , error ) ;
450
+ qmLog . info ( '$scope.syncTrackingReminderNotifications : ' , error ) ;
478
451
hideInboxLoader ( ) ;
479
452
} ) ;
480
453
} ;
0 commit comments