diff options
author | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-17 09:41:21 +0200 |
---|---|---|
committer | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-17 09:41:21 +0200 |
commit | f9bb000ccf9cb6bfa5be3af68ec319f346b313f1 (patch) | |
tree | e143a7b62ccb1c25ad207a1ed90b246699c1c24f /webclient/room/room-controller.js | |
parent | Bugfix when content isn't a string. (diff) | |
download | synapse-f9bb000ccf9cb6bfa5be3af68ec319f346b313f1.tar.xz |
WEB-35: joins/parts should trigger desktop notifications
Diffstat (limited to '')
-rw-r--r-- | webclient/room/room-controller.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index f82f4aed27..6e1d83a23d 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -143,7 +143,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) }); $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) { // The user has successfully joined the room, we can getting data for this room $scope.state.waiting_for_joined_event = false; @@ -161,19 +161,33 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) else { user = event.user_id; } - if ("ban" === event.membership) { $scope.state.permission_denied = "You have been banned by " + user; } else { $scope.state.permission_denied = "You have been kicked by " + user; - } - + } } else { scrollToBottom(); 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); + } } } }); |