0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-30 18:03:54 +01:00

WEB-35: joins/parts should trigger desktop notifications

This commit is contained in:
Emmanuel ROHEE 2014-09-17 09:41:21 +02:00
parent d6c0cff3bd
commit f9bb000ccf

View file

@ -143,7 +143,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
}); });
$scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) { $scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) {
if (isLive) { if (isLive && event.room_id === $scope.room_id) {
if ($scope.state.waiting_for_joined_event) { if ($scope.state.waiting_for_joined_event) {
// The user has successfully joined the room, we can getting data for this room // The user has successfully joined the room, we can getting data for this room
$scope.state.waiting_for_joined_event = false; $scope.state.waiting_for_joined_event = false;
@ -162,18 +162,32 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
user = event.user_id; user = event.user_id;
} }
if ("ban" === event.membership) { if ("ban" === event.membership) {
$scope.state.permission_denied = "You have been banned by " + user; $scope.state.permission_denied = "You have been banned by " + user;
} }
else { else {
$scope.state.permission_denied = "You have been kicked by " + user; $scope.state.permission_denied = "You have been kicked by " + user;
} }
} }
else { else {
scrollToBottom(); scrollToBottom();
updateMemberList(event); updateMemberList(event);
// Notify when a user joins
if ((document.hidden || matrixService.presence.unavailable === mPresence.getState())
&& event.state_key !== $scope.state.user_id && "join" === event.membership) {
debugger;
var notification = new window.Notification(
event.content.displayname +
" (" + (matrixService.getRoomIdToAliasMapping(event.room_id) || event.room_id) + ")", // FIXME: don't leak room_ids here
{
"body": event.content.displayname + " joined",
"icon": event.content.avatar_url ? event.content.avatar_url : undefined
});
$timeout(function() {
notification.close();
}, 5 * 1000);
}
} }
} }
}); });