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.
parent
f21960ec9d
commit
5ab9929cbb
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue