From f8571ec5d5c34ead9e9f491fbf728339400fa9d6 Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Sun, 16 Jul 2017 10:24:09 -0600 Subject: [PATCH] Moved notifications to be read after yesterdailies (#8872) * Moved notifications to be read after yesterdailies * Prevent when user needs cron * Updated tests --- .../spec/controllers/notificationCtrlSpec.js | 1 + website/client-old/js/controllers/notificationCtrl.js | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/client-old/spec/controllers/notificationCtrlSpec.js b/test/client-old/spec/controllers/notificationCtrlSpec.js index bb4caae6a1..a47acfbddb 100644 --- a/test/client-old/spec/controllers/notificationCtrlSpec.js +++ b/test/client-old/spec/controllers/notificationCtrlSpec.js @@ -6,6 +6,7 @@ describe('Notification Controller', function() { beforeEach(function() { user = specHelper.newUser(); user._id = "unique-user-id"; + user.needsCron = false; var userSync = sinon.stub().returns({ then: function then (f) { f(); } diff --git a/website/client-old/js/controllers/notificationCtrl.js b/website/client-old/js/controllers/notificationCtrl.js index dc55e8395c..0653b88e10 100644 --- a/website/client-old/js/controllers/notificationCtrl.js +++ b/website/client-old/js/controllers/notificationCtrl.js @@ -39,6 +39,7 @@ habitrpg.controller('NotificationCtrl', if (yesterDailies.length === 0) { User.runCron().then(function () { isRunningYesterdailies = false; + handleUserNotifications(User.user); }); return; }; @@ -73,6 +74,7 @@ habitrpg.controller('NotificationCtrl', User.runCron() .then(function () { isRunningYesterdailies = false; + handleUserNotifications(User.user); }); }; }], @@ -313,13 +315,14 @@ habitrpg.controller('NotificationCtrl', // are now stored in user.notifications. $rootScope.$watchCollection('userNotifications', function (after) { if (!User.user._wrapped) return; + if (User.user.needsCron) return; handleUserNotifications(after); }); - var handleUserNotificationsOnFirstSync = _.once(function () { - handleUserNotifications($rootScope.userNotifications); - }); - $rootScope.$on('userUpdated', handleUserNotificationsOnFirstSync); + // var handleUserNotificationsOnFirstSync = _.once(function () { + // handleUserNotifications($rootScope.userNotifications); + // }); + // $rootScope.$on('userUpdated', handleUserNotificationsOnFirstSync); // TODO what about this? $rootScope.$watch('user.achievements', function(){