mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
add notifications for real time messages
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('habitrpg')
|
||||
.factory('Pusher', ['$rootScope', 'STORAGE_SETTINGS_ID', 'Groups', 'Shared',
|
||||
function($rootScope, STORAGE_SETTINGS_ID, Groups, Shared) {
|
||||
.factory('Pusher', ['$rootScope', 'STORAGE_SETTINGS_ID', 'Groups', 'Shared', '$state', 'Chat',
|
||||
function($rootScope, STORAGE_SETTINGS_ID, Groups, Shared, $state, Chat) {
|
||||
var settings = JSON.parse(localStorage.getItem(STORAGE_SETTINGS_ID));
|
||||
var IS_PUSHER_ENABLED = window.env['PUSHER:ENABLED'] === 'true';
|
||||
|
||||
@@ -47,7 +47,7 @@ angular.module('habitrpg')
|
||||
});
|
||||
|
||||
api.pusher.connection.bind('connected', function () {
|
||||
api.socketId = api.pusher.connection.socket_id;
|
||||
$rootScope.pusherSocketId = api.socketId = api.pusher.connection.socket_id;
|
||||
});
|
||||
|
||||
var partyChannelName = 'presence-group-' + partyId;
|
||||
@@ -114,6 +114,15 @@ angular.module('habitrpg')
|
||||
_.assign($rootScope.party, syncedParty);
|
||||
});
|
||||
}
|
||||
|
||||
if ($state.is('options.social.party')) { // 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] = {
|
||||
name: $rootScope.party.name,
|
||||
value: true,
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user