diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-03 11:44:39 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-03 11:44:39 +0000 |
commit | 6bc1dc40208fd1c49591dbc8cb2b9a341b96f576 (patch) | |
tree | af60e7400e6a780165b05f396a8c3c5f2ebd6f57 /webclient/components | |
parent | Make call stuff use modelService. (diff) | |
download | synapse-6bc1dc40208fd1c49591dbc8cb2b9a341b96f576.tar.xz |
Make recents[controller/filter/html] use modelService.
This breaks functionality whilst both events.rooms and modelService are in use.
Diffstat (limited to 'webclient/components')
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 46 | ||||
-rw-r--r-- | webclient/components/matrix/model-service.js | 10 |
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; } }; |