From 2d6223377fee037be55e47273c0f18e2c6a32b94 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Fri, 9 Sep 2016 21:34:24 +0200 Subject: [PATCH] chat: better behavior for menu notification --- website/client/js/services/pusherService.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/website/client/js/services/pusherService.js b/website/client/js/services/pusherService.js index b0a2ee3bc2..fd2a873c5a 100644 --- a/website/client/js/services/pusherService.js +++ b/website/client/js/services/pusherService.js @@ -144,7 +144,10 @@ angular.module('habitrpg') }); } - if ($state.is('options.social.party') && document.hasFocus()) { // if we're on the party page, mark the chat as read + var docHasFocus = document.hasFocus(); + var isOnPartyPage = $state.is('options.social.party'); + + if (isOnPartyPage && docHasFocus) { // if we're on the party page, mark the chat as read Chat.markChatSeen($rootScope.party._id); } else { // show a notification $rootScope.User.user.newMessages[$rootScope.party._id] = { @@ -161,7 +164,8 @@ angular.module('habitrpg') }); notif.addEventListener('click', function () { - $state.go('options.social.party'); + if (!isOnPartyPage) $state.go('options.social.party'); + if (!docHasFocus) Chat.markChatSeen($rootScope.party._id); notif.close(); }); } else { @@ -169,7 +173,8 @@ angular.module('habitrpg') groupName: $rootScope.party.name, authorName: chatData.user || chatData.uuid, }), function() { - $state.go('options.social.party'); + if (!isOnPartyPage) $state.go('options.social.party'); + if (!docHasFocus) Chat.markChatSeen($rootScope.party._id); }); } }