summary refs log tree commit diff
path: root/webclient/components
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-15 15:40:37 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-15 17:42:11 +0100
commit02e45da895133ebe80866b1374ad86ab64cc7fb9 (patch)
tree9c68b8bdfd2f6bf01bcb2b995f48e25042c76a66 /webclient/components
parentDocument that /rooms/:room_id/members/list yields profile and presence inform... (diff)
downloadsynapse-02e45da895133ebe80866b1374ad86ab64cc7fb9.tar.xz
When new invites come down, update the My Rooms list. Added hacks to make the display name a bit nicer (/im/sync needs to return room aliases / membership events better)
Diffstat (limited to 'webclient/components')
-rw-r--r--webclient/components/matrix/event-handler-service.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js
index f7411fd80a..b8529895fe 100644
--- a/webclient/components/matrix/event-handler-service.js
+++ b/webclient/components/matrix/event-handler-service.js
@@ -33,23 +33,24 @@ angular.module('eventHandlerService', [])
     var PRESENCE_EVENT = "PRESENCE_EVENT";
     
     $rootScope.events = {
-        rooms: {}, // will contain roomId: { messages:[], members:[] }
+        rooms: {}, // will contain roomId: { messages:[], members:{userid1: event} }
     };
     
     var initRoom = function(room_id) {
-        console.log("Creating new handler entry for " + room_id);
-        $rootScope.events.rooms[room_id] = {};
-        $rootScope.events.rooms[room_id].messages = [];
-        $rootScope.events.rooms[room_id].members = [];
+        if (!(room_id in $rootScope.events.rooms)) {
+            console.log("Creating new handler entry for " + room_id);
+            $rootScope.events.rooms[room_id] = {};
+            $rootScope.events.rooms[room_id].messages = [];
+            $rootScope.events.rooms[room_id].members = {};
+        }
     }
     
     var handleMessage = function(event, isLiveEvent) {
         if ("membership_target" in event.content) {
             event.user_id = event.content.membership_target;
         }
-        if (!(event.room_id in $rootScope.events.rooms)) {
-            initRoom(event.room_id);
-        }
+        
+        initRoom(event.room_id);
         
         if (isLiveEvent) {
             $rootScope.events.rooms[event.room_id].messages.push(event);
@@ -67,6 +68,8 @@ angular.module('eventHandlerService', [])
     };
     
     var handleRoomMember = function(event, isLiveEvent) {
+        initRoom(event.room_id);
+        $rootScope.events.rooms[event.room_id].members[event.user_id] = event;
         $rootScope.$broadcast(MEMBER_EVENT, event, isLiveEvent);
     };