summary refs log tree commit diff
path: root/webclient/components
diff options
context:
space:
mode:
Diffstat (limited to 'webclient/components')
-rw-r--r--webclient/components/matrix/event-handler-service.js46
-rw-r--r--webclient/components/matrix/model-service.js10
2 files changed, 43 insertions, 13 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js
index dc00d83f33..9d33b6715e 100644
--- a/webclient/components/matrix/event-handler-service.js
+++ b/webclient/components/matrix/event-handler-service.js
@@ -86,18 +86,6 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService
             }
             $rootScope.events.rooms[room_id].membership = room.membership;
         }
-        
-        // =========================================
-        var __room = modelService.getRoom(room_id);
-        if (room) { // /initialSync data
-            __room.current_room_state.storeStateEvents(room.state);
-            __room.current_room_state.pagination_token = room.messages.end;
-            
-            __room.old_room_state.storeStateEvents(room.state);
-            __room.old_room_state.pagination_token = room.messages.start;
-            
-            $rootScope["debug_"+room_id] = __room;
-        }
     };
 
     var resetRoomMessages = function(room_id) {
@@ -621,12 +609,44 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService
                 var room = rooms[i];
 
                 this.initRoom(room);
+                
+                // FIXME: This is ming: the HS should be sending down the m.room.member
+                // event for the invite in .state but it isn't, so fudge it for now.
+                if (room.inviter && room.membership === "invite") {
+                    var me = matrixService.config().user_id;
+                    var fakeEvent = {
+                        event_id: "__FAKE__" + room.room_id,
+                        user_id: room.inviter,
+                        origin_server_ts: 0,
+                        room_id: room.room_id,
+                        state_key: me,
+                        type: "m.room.member",
+                        content: {
+                            membership: "invite"
+                        }
+                    };
+                    if (!room.state) {
+                        room.state = [];
+                    }
+                    room.state.push(fakeEvent);
+                    console.log("RECV /initialSync invite >> "+JSON.stringify(fakeEvent));
+                }
+                
+                // ========================================= 
+                var __room = modelService.getRoom(room.room_id);
+                __room.current_room_state.storeStateEvents(room.state);
+                __room.old_room_state.storeStateEvents(room.state);
+                
+                
+
 
                 if ("messages" in room) {
                     this.handleRoomMessages(room.room_id, room.messages, false);
+                    __room.current_room_state.pagination_token = room.messages.end;
+                    __room.old_room_state.pagination_token = room.messages.start;
                 }
 
-                if ("state" in room) {
+                if ("state" in room) { // TODO FIXME  remove this.
                     this.handleEvents(room.state, false, true);
                 }
             }
diff --git a/webclient/components/matrix/model-service.js b/webclient/components/matrix/model-service.js
index 26349f1461..ff6abfe422 100644
--- a/webclient/components/matrix/model-service.js
+++ b/webclient/components/matrix/model-service.js
@@ -100,9 +100,15 @@ angular.module('modelService', [])
         
         storeStateEvent: function storeState(event) {
             this.state_events[event.type + event.state_key] = event;
+            if (event.type === "m.room.member") {
+                this.members[event.state_key] = event;
+            }
         },
         
         storeStateEvents: function storeState(events) {
+            if (!events) {
+                return;
+            }
             for (var i=0; i<events.length; i++) {
                 this.storeStateEvent(events[i]);
             }
@@ -138,6 +144,10 @@ angular.module('modelService', [])
                 rooms[roomId] = new Room(roomId);
             }
             return rooms[roomId];
+        },
+        
+        getRooms: function() {
+            return rooms;
         }
     
     };