summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--webclient/components/matrix/event-handler-service.js15
-rw-r--r--webclient/components/matrix/event-stream-service.js11
2 files changed, 13 insertions, 13 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js
index 14ac79dd8f..d7705c8e3e 100644
--- a/webclient/components/matrix/event-handler-service.js
+++ b/webclient/components/matrix/event-handler-service.js
@@ -105,7 +105,7 @@ angular.module('eventHandlerService', [])
         $rootScope.$broadcast(MSG_EVENT, event, isLiveEvent);
     };
     
-    var handleRoomMember = function(event, isLiveEvent) {
+    var handleRoomMember = function(event, isLiveEvent, isStateEvent) {
         initRoom(event.room_id);
         
         // if the server is stupidly re-relaying a no-op join, discard it.
@@ -117,7 +117,10 @@ angular.module('eventHandlerService', [])
         }
         
         // add membership changes as if they were a room message if something interesting changed
-        if (event.content.prev !== event.content.membership) {
+        // Exception: Do not do this if the event is a room state event because such events already come
+        // as room messages events. Moreover, when they come as room messages events, they are relatively ordered
+        // with other other room messages
+        if (event.content.prev !== event.content.membership && !isStateEvent) {
             if (isLiveEvent) {
                 $rootScope.events.rooms[event.room_id].messages.push(event);
             }
@@ -191,7 +194,7 @@ angular.module('eventHandlerService', [])
         CALL_EVENT: CALL_EVENT,
         NAME_EVENT: NAME_EVENT,
     
-        handleEvent: function(event, isLiveEvent) {
+        handleEvent: function(event, isLiveEvent, isStateEvent) {
             // Avoid duplicated events
             // Needed for rooms where initialSync has not been done. 
             // In this case, we do not know where to start pagination. So, it starts from the END
@@ -222,7 +225,7 @@ angular.module('eventHandlerService', [])
                         handleMessage(event, isLiveEvent);
                         break;
                     case "m.room.member":
-                        handleRoomMember(event, isLiveEvent);
+                        handleRoomMember(event, isLiveEvent, isStateEvent);
                         break;
                     case "m.presence":
                         handlePresence(event, isLiveEvent);
@@ -250,9 +253,9 @@ angular.module('eventHandlerService', [])
         
         // isLiveEvents determines whether notifications should be shown, whether
         // messages get appended to the start/end of lists, etc.
-        handleEvents: function(events, isLiveEvents) {
+        handleEvents: function(events, isLiveEvents, isStateEvents) {
             for (var i=0; i<events.length; i++) {
-                this.handleEvent(events[i], isLiveEvents);
+                this.handleEvent(events[i], isLiveEvents, isStateEvents);
             }
         },
 
diff --git a/webclient/components/matrix/event-stream-service.js b/webclient/components/matrix/event-stream-service.js
index d7ccc63e89..249af193df 100644
--- a/webclient/components/matrix/event-stream-service.js
+++ b/webclient/components/matrix/event-stream-service.js
@@ -113,15 +113,12 @@ angular.module('eventStreamService', [])
                 for (var i = 0; i < rooms.length; ++i) {
                     var room = rooms[i];
 
-                    // console.log("got room: " + room.room_id);
-                    if ("state" in room) {
-                        //eventHandlerService.handleEvents(room.state, false);
-                    }
-
                     if ("messages" in room) {
                         eventHandlerService.handleRoomMessages(room.room_id, room.messages, false);
-                        
-                        console.log(room.messages.start + " - " + room.messages.end);
+                    }
+                    
+                    if ("state" in room) {
+                        eventHandlerService.handleEvents(room.state, false, true);
                     }
                 }