summary refs log tree commit diff
path: root/webclient/recents/recents-controller.js
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-08-27 18:52:02 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-08-27 18:52:15 +0200
commit04fdcf302d04daedaef7a1d1b796832a9dc31b74 (patch)
treeb3dfa4d5a83b8b7ff501ad567967f6368f46a3c7 /webclient/recents/recents-controller.js
parentMerge branch 'develop' into storage_transactions (diff)
downloadsynapse-04fdcf302d04daedaef7a1d1b796832a9dc31b74.tar.xz
Wired the recents list with the stream events for realtime update
Diffstat (limited to 'webclient/recents/recents-controller.js')
-rw-r--r--webclient/recents/recents-controller.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js
index 8f8b08d5bd..bf6a1b8874 100644
--- a/webclient/recents/recents-controller.js
+++ b/webclient/recents/recents-controller.js
@@ -25,22 +25,23 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService'])
     // in order to highlight a specific room in the list
     $scope.recentsSelectedRoomID;
 
+    // Refresh the list on matrix invitation and message event
     $scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) {
-        var config = matrixService.config();
-        if (event.state_key === config.user_id && event.content.membership === "invite") {
-            console.log("Invited to room " + event.room_id);
-            // FIXME push membership to top level key to match /im/sync
-            event.membership = event.content.membership;
-            // FIXME bodge a nicer name than the room ID for this invite.
-            event.room_display_name = event.user_id + "'s room";
-            $scope.rooms[event.room_id] = event;
-        }
+        refresh();
+    });
+    $scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) {
+        refresh();
     });
     
     var refresh = function() {
         // List all rooms joined or been invited to
+        // TODO: This is a pity that event-stream-service.js makes the same call
+        // We should be able to reuse event-stream-service.js fetched data
         matrixService.rooms(1, false).then(
             function(response) {
+                // Reset data
+                $scope.rooms = {};
+
                 var data = matrixService.assignRoomAliases(response.data.rooms);
                 for (var i=0; i<data.length; i++) {
                     $scope.rooms[data[i].room_id] = data[i];