Skip to content

Commit 0d1b5aa

Browse files
committed
rtc fixes: do not show notification if message was sent by current user from different computer or mobile, put back message syncing on posting for guilds and tavern
1 parent 1484f8a commit 0d1b5aa

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

website/client-old/js/controllers/chatCtrl.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ habitrpg.controller('ChatCtrl', ['$scope', 'Groups', 'Chat', 'User', '$http', 'A
2626
$scope.postChat = function(group, message){
2727
if (_.isEmpty(message) || $scope._sending) return;
2828
$scope._sending = true;
29-
// var previousMsg = (group.chat && group.chat[0]) ? group.chat[0].id : false;
30-
Chat.postChat(group._id, message) //, previousMsg) not sending the previousMsg as we have real time updates
29+
30+
var previousMsg = false;
31+
if (group.type !== 'party' && group.chat && group.chat[0]) { // not sending the previousMsg for parties as we have real time updates
32+
previousMsg = group.chat[0].id;
33+
}
34+
35+
Chat.postChat(group._id, message, previousMsg)
3136
.then(function(response) {
3237
var message = response.data.data.message;
3338

website/client-old/js/services/pusherService.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ angular.module('habitrpg')
115115

116116
// When the user is booted from the party, they get disconnected from Pusher
117117
partyChannel.bind('user-removed', function (data) {
118-
if (data.userId === user._id) {
118+
if (data.userId === $rootScope.User.user._id) {
119119
api.pusher.unsubscribe(partyChannelName);
120120
}
121121
});
122122

123123
// Same when the user leaves the party
124124
partyChannel.bind('user-left', function (data) {
125-
if (data.userId === user._id) {
125+
if (data.userId === $rootScope.User.user._id) {
126126
api.pusher.unsubscribe(partyChannelName);
127127
}
128128
});
@@ -147,7 +147,8 @@ angular.module('habitrpg')
147147
var docHasFocus = document.hasFocus();
148148
var isOnPartyPage = $state.is('options.social.party');
149149

150-
if (isOnPartyPage && docHasFocus) { // if we're on the party page, mark the chat as read
150+
// if we're on the party page or the message was sent by us, mark the chat as read but don't show notifications
151+
if ((isOnPartyPage && docHasFocus) || chatData.uuid === $rootScope.User.user._id) {
151152
Chat.markChatSeen($rootScope.party._id);
152153
} else { // show a notification
153154
$rootScope.User.user.newMessages[$rootScope.party._id] = {
@@ -160,7 +161,7 @@ angular.module('habitrpg')
160161
groupName: $rootScope.party.name,
161162
}), {
162163
body: (chatData.user || chatData.uuid) + ': ' + chatData.text,
163-
icon: '/common/img/gryphon_192-20.png'
164+
icon: '/common/img/gryphon_192-20.png',
164165
});
165166

166167
notif.addEventListener('click', function () {

0 commit comments

Comments
 (0)