@@ -8,7 +8,7 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
8
8
qmLog . debug ( 'Loading ' + $scope . controller_name ) ;
9
9
qmService . navBar . setFilterBarSearchIcon ( false ) ;
10
10
$scope . state = {
11
- maximumNotificationsToDisplay : 20 ,
11
+ maximumNotificationsToDisplay : 10 , // I think more might slow it down?
12
12
showMeasurementBox : false ,
13
13
selectedReminder : false ,
14
14
reminderDefaultValue : "" ,
@@ -186,8 +186,9 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
186
186
trackingReminderNotification . modifiedValue = trackingReminderNotification . total ;
187
187
var lastAction = 'Recorded ' + trackingReminderNotification . modifiedValue + ' ' + trackingReminderNotification . unitAbbreviatedName ;
188
188
qm . notifications . lastAction = qm . stringHelper . formatValueUnitDisplayText ( lastAction ) + ' for ' + trackingReminderNotification . variableName ;
189
- notificationAction ( trackingReminderNotification ) ;
190
- qm . notifications . trackNotification ( trackingReminderNotification ) ;
189
+ notificationAction ( trackingReminderNotification , function ( params ) {
190
+ qm . notifications . trackNotification ( params ) ;
191
+ } ) ;
191
192
refreshIfRunningOutOfNotifications ( ) ;
192
193
} ;
193
194
function getFavorites ( ) {
@@ -235,18 +236,31 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
235
236
} ) ;
236
237
}
237
238
} ;
238
- var notificationAction = function ( trackingReminderNotification ) {
239
- trackingReminderNotification = qmService . notifications . handleNotificationAction ( trackingReminderNotification ,
240
- getTrackingReminderNotifications ) ;
239
+ var notificationAction = function ( n , cb ) {
240
+ qmLog . info ( "Clicked " + qm . notifications . lastAction + " for " + n . variableName ) ;
241
+ n . hide = true ;
242
+ qm . notifications . numberOfPendingNotifications -- ;
243
+ qmService . notifications . undo = false
244
+ qmService . showToastWithButton ( qm . notifications . lastAction , 'UNDO' , function ( ) {
245
+ qmService . notifications . undo = true
246
+ } ) ;
247
+ if ( ! n . trackingReminderNotificationId ) { n . trackingReminderNotificationId = n . id ; }
241
248
$scope . state . numberOfDisplayedNotifications -- ;
242
249
if ( $state . current . name === "app.remindersInboxCompact" ) {
243
- if ( ! $scope . state . numberOfDisplayedNotifications ) {
244
- window . close ( ) ;
245
- }
250
+ if ( ! $scope . state . numberOfDisplayedNotifications ) { window . close ( ) ; }
246
251
$scope . trackingReminderNotifications . shift ( ) ;
247
252
}
253
+ setTimeout ( function ( ) {
254
+ if ( qmService . notifications . undo ) {
255
+ n . hide = false ;
256
+ getTrackingReminderNotifications ( ) ;
257
+ qmService . notifications . undo = false ;
258
+ } else {
259
+ cb ( n ) ;
260
+ }
261
+ } , 5000 )
248
262
closeWindowIfNecessary ( ) ;
249
- return trackingReminderNotification ;
263
+ return n ;
250
264
} ;
251
265
$scope . track = function ( notification , value , $event ) {
252
266
if ( isGhostClick ( $event ) ) { return false ; }
@@ -255,9 +269,10 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
255
269
var variableName = notification . variableName ;
256
270
valueUnit = qm . stringHelper . formatValueUnitDisplayText ( valueUnit ) ;
257
271
qm . notifications . lastAction = 'Recorded ' + valueUnit + ' for ' + variableName ;
258
- var body = notificationAction ( notification ) ;
259
- if ( value !== null ) { body . modifiedValue = value ; }
260
- qm . notifications . trackNotification ( body ) ;
272
+ notificationAction ( notification , function ( params ) {
273
+ if ( value !== null ) { params . modifiedValue = value ; }
274
+ qm . notifications . trackNotification ( params ) ;
275
+ } ) ;
261
276
refreshIfRunningOutOfNotifications ( ) ;
262
277
if ( $scope . state . showTrackAllButtons ) {
263
278
qm . toast . showQuestionToast ( 'Want to record ' + valueUnit + " for ALL remaining " + variableName + " notifications?" ,
@@ -270,9 +285,10 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
270
285
notification . modifiedValue = value ;
271
286
var lastAction = 'Recorded ' + value + ' ' + notification . unitAbbreviatedName ;
272
287
qm . notifications . lastAction = qm . stringHelper . formatValueUnitDisplayText ( lastAction ) + ' for all ' + notification . variableName ;
273
- var body = notificationAction ( notification ) ;
274
- qmService . notifications . trackAll ( body , value , ev ) ;
275
- getTrackingReminderNotifications ( ) ;
288
+ notificationAction ( notification , function ( params ) {
289
+ qmService . notifications . trackAll ( params , value , ev ) ;
290
+ getTrackingReminderNotifications ( ) ;
291
+ } ) ;
276
292
}
277
293
$scope . trackAllWithConfirmation = function ( trackingReminderNotification , modifiedReminderValue , ev ) {
278
294
qm . ui . preventDragAfterAlert ( ev ) ;
@@ -291,18 +307,18 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
291
307
return ;
292
308
}
293
309
qm . notifications . lastAction = 'Skipped ' + trackingReminderNotification . variableName ;
294
- var params = notificationAction ( trackingReminderNotification ) ;
295
- qm . notifications . skip ( params ) ;
296
- qmService . logEventToGA ( qm . analytics . eventCategories . inbox , "skip" ) ;
310
+ notificationAction ( trackingReminderNotification , function ( params ) {
311
+ qm . notifications . skip ( params ) ;
312
+ qmService . logEventToGA ( qm . analytics . eventCategories . inbox , "skip" ) ;
313
+ } ) ;
297
314
refreshIfRunningOutOfNotifications ( ) ;
298
315
} ;
299
316
$scope . snooze = function ( trackingReminderNotification , $event ) {
300
- if ( isGhostClick ( $event ) ) {
301
- return ;
302
- }
317
+ if ( isGhostClick ( $event ) ) { return ; }
303
318
qm . notifications . lastAction = 'Snoozed ' + trackingReminderNotification . variableName ;
304
- var params = notificationAction ( trackingReminderNotification ) ;
305
- qm . notifications . snoozeNotification ( params ) ;
319
+ notificationAction ( trackingReminderNotification , function ( params ) {
320
+ qm . notifications . snoozeNotification ( params ) ;
321
+ } ) ;
306
322
qmService . logEventToGA ( qm . analytics . eventCategories . inbox , "snooze" ) ;
307
323
refreshIfRunningOutOfNotifications ( ) ;
308
324
} ;
0 commit comments