diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-03 09:44:20 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-03 09:44:20 +0000 |
commit | 5ab9929cbb3dd7b908011888e79fdb7bf54a5296 (patch) | |
tree | 27cade25de50fc69e8481ec3713db124a20c42c7 /webclient | |
parent | Replace lots of .events.rooms[room_id] with .room (diff) | |
download | synapse-5ab9929cbb3dd7b908011888e79fdb7bf54a5296.tar.xz |
Prevent EventStreamService from knowing too much about the EventHandlerService by changing the contract to just be a single initialSync response callback. Leave it up the handler to deal with splitting out information from /initialSync.
Diffstat (limited to 'webclient')
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 22 | ||||
-rw-r--r-- | webclient/components/matrix/event-stream-service.js | 19 |
2 files changed, 20 insertions, 21 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index f8a91ee0ac..c11391a6da 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -613,9 +613,27 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService } }, - handleInitialSyncDone: function(initialSyncData) { + handleInitialSyncDone: function(response) { console.log("# handleInitialSyncDone"); - initialSyncDeferred.resolve(initialSyncData); + + var rooms = response.data.rooms; + for (var i = 0; i < rooms.length; ++i) { + var room = rooms[i]; + + this.initRoom(room); + + if ("messages" in room) { + this.handleRoomMessages(room.room_id, room.messages, false); + } + + if ("state" in room) { + this.handleEvents(room.state, false, true); + } + } + var presence = response.data.presence; + this.handleEvents(presence, false); + + initialSyncDeferred.resolve(response); }, // Returns a promise that resolves when the initialSync request has been processed diff --git a/webclient/components/matrix/event-stream-service.js b/webclient/components/matrix/event-stream-service.js index 05469a3ded..c03f0b953b 100644 --- a/webclient/components/matrix/event-stream-service.js +++ b/webclient/components/matrix/event-stream-service.js @@ -109,25 +109,6 @@ angular.module('eventStreamService', []) // without requiring to make an additional request matrixService.initialSync(30, false).then( function(response) { - var rooms = response.data.rooms; - for (var i = 0; i < rooms.length; ++i) { - var room = rooms[i]; - - eventHandlerService.initRoom(room); - - if ("messages" in room) { - eventHandlerService.handleRoomMessages(room.room_id, room.messages, false); - } - - if ("state" in room) { - eventHandlerService.handleEvents(room.state, false, true); - } - } - - var presence = response.data.presence; - eventHandlerService.handleEvents(presence, false); - - // Initial sync is done eventHandlerService.handleInitialSyncDone(response); // Start event streaming from that point |