summary refs log tree commit diff
path: root/webclient/components
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-11-03 17:44:14 +0000
committerKegan Dougal <kegan@matrix.org>2014-11-03 17:44:14 +0000
commit4b3f74388570f104ebd3cae8543f1aaca1572127 (patch)
treecbbe60e0cc7c8bbdf2ce728071602bc1d1b2ea4d /webclient/components
parentVariable renaming, general cleanup. Don't feed state events from /initialSync... (diff)
downloadsynapse-4b3f74388570f104ebd3cae8543f1aaca1572127.tar.xz
Reference the room_member key on messages which adjusts for current vs old_room_state. This displays names for historical users correctly, but is off by one (referencing content not prev_content).
Diffstat (limited to 'webclient/components')
-rw-r--r--webclient/components/matrix/event-handler-service.js22
1 files changed, 16 insertions, 6 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js
index 7f53429754..eff8674e04 100644
--- a/webclient/components/matrix/event-handler-service.js
+++ b/webclient/components/matrix/event-handler-service.js
@@ -193,6 +193,17 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService
     var handleRoomMember = function(event, isLiveEvent, isStateEvent) {
         var room = modelService.getRoom(event.room_id);
         
+        // modify state before adding the message so it points to the right thing.
+        // The events are copied to avoid referencing the same event when adding
+        // the message (circular json structures)
+        if (isStateEvent || isLiveEvent) {
+            room.current_room_state.storeStateEvent(angular.copy(event));
+        }
+        else if (!isLiveEvent) {
+            // mutate the old room state
+            room.old_room_state.storeStateEvent(angular.copy(event));
+        }
+        
         
         // add membership changes as if they were a room message if something interesting changed
         // Exception: Do not do this if the event is a room state event because such events already come
@@ -220,11 +231,7 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService
             }
         }
         
-        // Use data from state event or the latest data from the stream.
-        // Do not care of events that come when paginating back
-        if (isStateEvent || isLiveEvent) {
-            room.current_room_state.members[event.state_key] = event;
-        }
+        
         
         $rootScope.$broadcast(MEMBER_EVENT, event, isLiveEvent, isStateEvent);
     };
@@ -439,7 +446,8 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService
 
             }
             else {
-                // InitialSync returns messages in chronological order
+                // InitialSync returns messages in chronological order, so invert
+                // it to get most recent > oldest
                 for (var i=events.length - 1; i>=0; i--) {
                     this.handleEvent(events[i], isLiveEvents, isLiveEvents);
                 }
@@ -482,6 +490,8 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService
                 newRoom.current_room_state.storeStateEvents(room.state);
                 newRoom.old_room_state.storeStateEvents(room.state);
 
+                // this should be done AFTER storing state events since these
+                // messages may make the old_room_state diverge.
                 if ("messages" in room) {
                     this.handleRoomMessages(room.room_id, room.messages, false);
                     newRoom.current_room_state.pagination_token = room.messages.end;