summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xsyweb/webclient/app.css4
-rw-r--r--syweb/webclient/components/matrix/event-handler-service.js24
-rw-r--r--syweb/webclient/components/matrix/recents-service.js21
-rw-r--r--syweb/webclient/recents/recents-controller.js6
-rw-r--r--syweb/webclient/recents/recents.html2
5 files changed, 50 insertions, 7 deletions
diff --git a/syweb/webclient/app.css b/syweb/webclient/app.css
index 7a4ff0467b..648388cdb9 100755
--- a/syweb/webclient/app.css
+++ b/syweb/webclient/app.css
@@ -816,6 +816,10 @@ textarea, input {
     background-color: #fee;
 }
 
+.recentsRoomBing {
+    background-color: #eef;
+}
+
 .recentsRoomName {
     font-size: 16px;
     padding-top: 7px;
diff --git a/syweb/webclient/components/matrix/event-handler-service.js b/syweb/webclient/components/matrix/event-handler-service.js
index 7b2a75507d..6645d20374 100644
--- a/syweb/webclient/components/matrix/event-handler-service.js
+++ b/syweb/webclient/components/matrix/event-handler-service.js
@@ -95,14 +95,22 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
         modelService.createRoomIdToAliasMapping(event.room_id, event.content.aliases[0]);
     };
     
+    var containsBingWord = function(event) {
+        if (!event.content || !event.content.body) {
+            return false;
+        }
+    
+        return notificationService.containsBingWord(
+            matrixService.config().user_id,
+            matrixService.config().display_name,
+            matrixService.config().bingWords,
+            event.content.body
+        );
+    };
+    
     var displayNotification = function(event) {
         if (window.Notification && event.user_id != matrixService.config().user_id) {
-            var shouldBing = notificationService.containsBingWord(
-                matrixService.config().user_id,
-                matrixService.config().display_name,
-                matrixService.config().bingWords,
-                event.content.body
-            );
+            var shouldBing = containsBingWord(event);
 
             // Ideally we would notify only when the window is hidden (i.e. document.hidden = true).
             //
@@ -529,6 +537,10 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
             resetRoomMessages(room_id);
         },
         
+        eventContainsBingWord: function(event) {
+            return containsBingWord(event);
+        },
+        
         /**
          * Return the last message event of a room
          * @param {String} room_id the room id
diff --git a/syweb/webclient/components/matrix/recents-service.js b/syweb/webclient/components/matrix/recents-service.js
index 237f1e3912..3d82b8218b 100644
--- a/syweb/webclient/components/matrix/recents-service.js
+++ b/syweb/webclient/components/matrix/recents-service.js
@@ -38,9 +38,22 @@ angular.module('recentsService', [])
         // room_id: <number>
     };
     
+    var BROADCAST_UNREAD_BING_MESSAGES = "recentsService:BROADCAST_UNREAD_BING_MESSAGES(room_id, event)";
+    var unreadBingMessages = {
+        // room_id: bingEvent
+    };
+    
     // listen for new unread messages
     $rootScope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) {
         if (isLive && event.room_id !== selectedRoomId) {
+            if (eventHandlerService.eventContainsBingWord(event)) {
+                if (!unreadBingMessages[event.room_id]) {
+                    unreadBingMessages[event.room_id] = {};
+                }
+                unreadBingMessages[event.room_id] = event;
+                $rootScope.$broadcast(BROADCAST_UNREAD_BING_MESSAGES, event.room_id, event);
+            }
+        
             if (!unreadMessages[event.room_id]) {
                 unreadMessages[event.room_id] = 0;
             }
@@ -66,11 +79,19 @@ angular.module('recentsService', [])
             return unreadMessages;
         },
         
+        getUnreadBingMessages: function() {
+            return unreadBingMessages;
+        },
+        
         markAsRead: function(room_id) {
             if (unreadMessages[room_id]) {
                 unreadMessages[room_id] = 0;
             }
+            if (unreadBingMessages[room_id]) {
+                unreadBingMessages[room_id] = undefined;
+            }
             $rootScope.$broadcast(BROADCAST_UNREAD_MESSAGES, room_id, 0);
+            $rootScope.$broadcast(BROADCAST_UNREAD_BING_MESSAGES, room_id, undefined);
         }
     
     };
diff --git a/syweb/webclient/recents/recents-controller.js b/syweb/webclient/recents/recents-controller.js
index 5c2cf270c3..41720d4cb0 100644
--- a/syweb/webclient/recents/recents-controller.js
+++ b/syweb/webclient/recents/recents-controller.js
@@ -38,6 +38,12 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter'])
         $scope.unreadMessages = recentsService.getUnreadMessages();
     });
     
+    // track the list of unread BING messages: the html will use this
+    $scope.unreadBings = recentsService.getUnreadBingMessages();
+    $scope.$on(recentsService.BROADCAST_UNREAD_BING_MESSAGES, function(ngEvent, room_id, event) {
+        $scope.unreadBings = recentsService.getUnreadBingMessages();
+    });
+    
     $scope.selectRoom = function(room) {
         recentsService.markAsRead(room.room_id);
         $rootScope.goToPage('room/' + (room.room_alias ? room.room_alias : room.room_id) );
diff --git a/syweb/webclient/recents/recents.html b/syweb/webclient/recents/recents.html
index 386edb1417..0b3a77ca11 100644
--- a/syweb/webclient/recents/recents.html
+++ b/syweb/webclient/recents/recents.html
@@ -3,7 +3,7 @@
         <tbody ng-repeat="(index, room) in rooms | orderRecents" 
                ng-click="selectRoom(room)" 
                class="recentsRoom"
-               ng-class="{'recentsRoomSelected': (room.room_id === recentsSelectedRoomID), 'recentsRoomUnread': (unreadMessages[room.room_id])}">
+               ng-class="{'recentsRoomSelected': (room.room_id === recentsSelectedRoomID), 'recentsRoomBing': (unreadBings[room.room_id]), 'recentsRoomUnread': (unreadMessages[room.room_id])}">
             <tr>
                 <td ng-class="room.current_room_state.state('m.room.join_rules').content.join_rule == 'public' ? 'recentsRoomName recentsPublicRoom' : 'recentsRoomName'">
                     {{ room.room_id | mRoomName }}