summary refs log tree commit diff
path: root/syweb/webclient/recents/recents-controller.js
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-11-12 14:31:30 +0000
committerKegan Dougal <kegan@matrix.org>2014-11-12 14:31:30 +0000
commite632fcd933b7259853ba0522e052e73fd4f4e71a (patch)
treef17d43d93bea6806bd4ded75457c33b63d87b5b9 /syweb/webclient/recents/recents-controller.js
parentRemove getRoomAliasAndDisplayName: room name logic is in mRoomName filter, an... (diff)
downloadsynapse-e632fcd933b7259853ba0522e052e73fd4f4e71a.tar.xz
SYWEB-57: Highlight rooms where the history has changed.
This highlights rooms when something has happened and you haven't viewed
it yet. It highlights entries in a slightly red background colour.
Diffstat (limited to 'syweb/webclient/recents/recents-controller.js')
-rw-r--r--syweb/webclient/recents/recents-controller.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/syweb/webclient/recents/recents-controller.js b/syweb/webclient/recents/recents-controller.js
index 6f0be18f1a..062d106018 100644
--- a/syweb/webclient/recents/recents-controller.js
+++ b/syweb/webclient/recents/recents-controller.js
@@ -25,10 +25,32 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter'])
     
     // retrieve all rooms and expose them
     $scope.rooms = modelService.getRooms();
+    
+    if (!$rootScope.unreadMessages) {
+        $rootScope.unreadMessages = {
+            // room_id: <number>
+        };
+    }
 
-    // $rootScope of the parent where the recents component is included can override this value
-    // in order to highlight a specific room in the list
-    $rootScope.recentsSelectedRoomID;
+    // $rootScope.recentsSelectedRoomID is used in the html, and is set by room-controller.
+    
+    
+    $scope.selectRoom = function(room) {
+        if ($rootScope.unreadMessages[room.room_id]) {
+            $rootScope.unreadMessages[room.room_id] = 0;
+        }
+        $rootScope.goToPage('room/' + (room.room_alias ? room.room_alias : room.room_id) );
+    };
+    
+    $scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) {
+        if (isLive && event.room_id !== $rootScope.recentsSelectedRoomID) {
+            if (!$rootScope.unreadMessages[event.room_id]) {
+                $rootScope.unreadMessages[event.room_id] = 0;
+            }
+            $rootScope.unreadMessages[event.room_id] += 1;
+            console.log("sel="+$rootScope.recentsSelectedRoomID+" unread:"+JSON.stringify($rootScope.unreadMessages, undefined, 2));
+        }
+    });
 
 }]);