chat: better behavior for menu notification

This commit is contained in:
Matteo Pagliazzi
2016-09-09 21:34:24 +02:00
parent 60f7a1dbd9
commit 2d6223377f

View File

@@ -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); Chat.markChatSeen($rootScope.party._id);
} else { // show a notification } else { // show a notification
$rootScope.User.user.newMessages[$rootScope.party._id] = { $rootScope.User.user.newMessages[$rootScope.party._id] = {
@@ -161,7 +164,8 @@ angular.module('habitrpg')
}); });
notif.addEventListener('click', function () { 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(); notif.close();
}); });
} else { } else {
@@ -169,7 +173,8 @@ angular.module('habitrpg')
groupName: $rootScope.party.name, groupName: $rootScope.party.name,
authorName: chatData.user || chatData.uuid, authorName: chatData.user || chatData.uuid,
}), function() { }), function() {
$state.go('options.social.party'); if (!isOnPartyPage) $state.go('options.social.party');
if (!docHasFocus) Chat.markChatSeen($rootScope.party._id);
}); });
} }
} }