fix(private-messages): clear newMessages both when leaving and entering inbox

This commit is contained in:
Tyler Renelle 2014-11-21 08:34:08 -07:00
parent a429dce5dd
commit 1539c35d29
2 changed files with 5 additions and 6 deletions

View file

@ -77,12 +77,7 @@ window.habitrpg = angular.module('habitrpg',
.state('options.social.inbox', {
url: "/inbox",
templateUrl: "partials/options.social.inbox.html",
controller: ['$rootScope', function($rootScope){
// clear "new messages"
//$rootScope.$on('userSynced',function(){
$rootScope.User.user.ops.update && $rootScope.set({'inbox.newMessages':0});
}]
templateUrl: "partials/options.social.inbox.html"
})
.state('options.social.tavern', {

View file

@ -16,6 +16,10 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
$rootScope.$on('$stateChangeSuccess',
function(event, toState, toParams, fromState, fromParams){
if (!!fromState.name) window.ga && ga('send', 'pageview', {page: '/#/'+toState.name});
// clear inbox when entering or exiting inbox tab
if (fromState.name=='options.social.inbox' || toState.name=='options.social.inbox') {
User.user.ops.update && User.set({'inbox.newMessages':0});
}
});
$rootScope.User = User;