From 941ff10cdceb59313d575aa6362844fc4ff2e93f Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 19 Jun 2016 08:38:07 -0500 Subject: [PATCH] fix: Prevent message from displaying if no new messages exist --- website/client/js/controllers/rootCtrl.js | 5 ++--- website/client/js/services/userServices.js | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/website/client/js/controllers/rootCtrl.js b/website/client/js/controllers/rootCtrl.js index 621b9be725..3e3429da98 100644 --- a/website/client/js/controllers/rootCtrl.js +++ b/website/client/js/controllers/rootCtrl.js @@ -22,8 +22,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ $rootScope.pageTitle = $state.current.title; if (!!fromState.name) Analytics.track({'hitType':'pageview','eventCategory':'navigation','eventAction':'navigate','page':'/#/'+toState.name}); - // clear inbox when entering inbox tab - if (toState.name=='options.social.inbox') { + if (toState.name=='options.social.inbox' && User.user.inbox && User.user.inbox.newMessages > 0) { User.clearNewMessages(); } }); @@ -44,7 +43,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ $rootScope.toJson = angular.toJson; $rootScope.Payments = Payments; $rootScope.userNotifications = []; - + // Angular UI Router $rootScope.$state = $state; $rootScope.$stateParams = $stateParams; diff --git a/website/client/js/services/userServices.js b/website/client/js/services/userServices.js index 67f3348033..21d024e9a7 100644 --- a/website/client/js/services/userServices.js +++ b/website/client/js/services/userServices.js @@ -14,8 +14,8 @@ angular.module('habitrpg') /** * Services that persists and retrieves user from localStorage. */ - .factory('User', ['$rootScope', '$http', '$location', '$window', 'STORAGE_USER_ID', 'STORAGE_SETTINGS_ID', 'Notification', 'ApiUrl', 'Tasks', 'Tags', 'Content', 'UserNotifications', - function($rootScope, $http, $location, $window, STORAGE_USER_ID, STORAGE_SETTINGS_ID, Notification, ApiUrl, Tasks, Tags, Content, UserNotifications) { + .factory('User', ['$rootScope', '$http', '$location', '$window', '$state', 'STORAGE_USER_ID', 'STORAGE_SETTINGS_ID', 'Notification', 'ApiUrl', 'Tasks', 'Tags', 'Content', 'UserNotifications', + function($rootScope, $http, $location, $window, $state, STORAGE_USER_ID, STORAGE_SETTINGS_ID, Notification, ApiUrl, Tasks, Tags, Content, UserNotifications) { var authenticated = false; var defaultSettings = { auth: { apiId: '', apiToken: ''}, @@ -106,7 +106,7 @@ angular.module('habitrpg') .then(function (response) { var tasks = response.data.data; syncUserTasks(tasks); - if ($rootScope.$state && $rootScope.$state.current.name=='options.social.inbox') { + if ($state.current.name=='options.social.inbox' && user.inbox.newMessages > 0) { userServices.clearNewMessages(); } $rootScope.$emit('userSynced');