From 8ca3144563b3f9f02447139a72325e57f634f893 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Wed, 25 May 2016 16:17:24 -0500 Subject: [PATCH] fix(crit): notify from server response (#7498) Fixes #3166. --- website/client/js/controllers/notificationCtrl.js | 8 -------- website/client/js/services/userServices.js | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/website/client/js/controllers/notificationCtrl.js b/website/client/js/controllers/notificationCtrl.js index 16a2c3a991..39dc1e4790 100644 --- a/website/client/js/controllers/notificationCtrl.js +++ b/website/client/js/controllers/notificationCtrl.js @@ -82,14 +82,6 @@ habitrpg.controller('NotificationCtrl', } }); - $rootScope.$watch('user._tmp.crit', function(after, before){ - if (after == before || !after) return; - var amount = User.user._tmp.crit * 100 - 100; - // reset the crit counter - User.user._tmp.crit = undefined; - Notification.crit(amount); - }); - $rootScope.$watch('user._tmp.drop', function(after, before){ // won't work when getting the same item twice? if (_.isEqual(after, before) || !after) return; diff --git a/website/client/js/services/userServices.js b/website/client/js/services/userServices.js index 255ac85d14..8b99c2c3b3 100644 --- a/website/client/js/services/userServices.js +++ b/website/client/js/services/userServices.js @@ -224,8 +224,13 @@ angular.module('habitrpg') Tasks.scoreTask(data.params.task._id, data.params.direction).then(function (res) { var tmp = res.data.data._tmp || {}; // used to notify drops, critical hits and other bonuses + var crit = tmp.crit; var drop = tmp.drop; + if (crit) { + var critBonus = crit * 100 - 100; + Notification.crit(critBonus); + } if (drop) user._tmp.drop = drop; }); },