From df5a43633863d2229aab80fb2ca4568142ebd246 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Sat, 23 Nov 2013 17:42:47 +0100 Subject: [PATCH] use countPets also for stats, fix #1898 --- public/js/controllers/rootCtrl.js | 6 ++++++ views/shared/profiles/stats.jade | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/public/js/controllers/rootCtrl.js b/public/js/controllers/rootCtrl.js index 607bd333e7..be95206e0f 100644 --- a/public/js/controllers/rootCtrl.js +++ b/public/js/controllers/rootCtrl.js @@ -24,6 +24,12 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ // count pets, mounts collected totals, etc $rootScope.countExists = function(items) {return _.reduce(items,function(m,v){return m+(v?1:0)},0)} + $rootScope.petCount = window.habitrpgShared.helpers.countPets(null, User.user.items.pets); + + $rootScope.$watch('user.items.pets', function(pets){ + $rootScope.petCount = window.habitrpgShared.helpers.countPets($rootScope.countExists(pets), User.user.items.pets); + }, true); + $scope.safeApply = function(fn) { var phase = this.$root.$$phase; if(phase == '$apply' || phase == '$digest') { diff --git a/views/shared/profiles/stats.jade b/views/shared/profiles/stats.jade index fc24520ea8..79075574fc 100644 --- a/views/shared/profiles/stats.jade +++ b/views/shared/profiles/stats.jade @@ -34,7 +34,7 @@ p span(popover-trigger='mouseenter', popover='(Level-1)/2') {{userDef(profile.stats.lvl)}} p strong Pets Found - | : {{countExists(profile.items.pets)}} + | : {{petCount}} hr p strong Total Experience Boost