diff --git a/website/client-old/js/controllers/chatCtrl.js b/website/client-old/js/controllers/chatCtrl.js index 649a06b9a7..f7f267a34b 100644 --- a/website/client-old/js/controllers/chatCtrl.js +++ b/website/client-old/js/controllers/chatCtrl.js @@ -26,8 +26,13 @@ habitrpg.controller('ChatCtrl', ['$scope', 'Groups', 'Chat', 'User', '$http', 'A $scope.postChat = function(group, message){ if (_.isEmpty(message) || $scope._sending) return; $scope._sending = true; - // var previousMsg = (group.chat && group.chat[0]) ? group.chat[0].id : false; - Chat.postChat(group._id, message) //, previousMsg) not sending the previousMsg as we have real time updates + + var previousMsg = false; + if (group.type !== 'party' && group.chat && group.chat[0]) { // not sending the previousMsg for parties as we have real time updates + previousMsg = group.chat[0].id; + } + + Chat.postChat(group._id, message, previousMsg) .then(function(response) { var message = response.data.data.message; diff --git a/website/client-old/js/services/pusherService.js b/website/client-old/js/services/pusherService.js index fd2a873c5a..53b7215892 100644 --- a/website/client-old/js/services/pusherService.js +++ b/website/client-old/js/services/pusherService.js @@ -115,14 +115,14 @@ angular.module('habitrpg') // When the user is booted from the party, they get disconnected from Pusher partyChannel.bind('user-removed', function (data) { - if (data.userId === user._id) { + if (data.userId === $rootScope.User.user._id) { api.pusher.unsubscribe(partyChannelName); } }); // Same when the user leaves the party partyChannel.bind('user-left', function (data) { - if (data.userId === user._id) { + if (data.userId === $rootScope.User.user._id) { api.pusher.unsubscribe(partyChannelName); } }); @@ -147,7 +147,8 @@ angular.module('habitrpg') 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 + // if we're on the party page or the message was sent by us, mark the chat as read but don't show notifications + if ((isOnPartyPage && docHasFocus) || chatData.uuid === $rootScope.User.user._id) { Chat.markChatSeen($rootScope.party._id); } else { // show a notification $rootScope.User.user.newMessages[$rootScope.party._id] = { @@ -160,7 +161,7 @@ angular.module('habitrpg') groupName: $rootScope.party.name, }), { body: (chatData.user || chatData.uuid) + ': ' + chatData.text, - icon: '/common/img/gryphon_192-20.png' + icon: '/common/img/gryphon_192-20.png', }); notif.addEventListener('click', function () {