1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

track kicked rooms correctly

This commit is contained in:
Matthew Hodgson
2016-03-19 02:18:37 +00:00
parent ad9daecbd4
commit 77101823f5

View File

@@ -719,14 +719,28 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) {
accountDataEvents.forEach(function(e) { client.emit("event", e); });
});
// Handle leaves
// Handle leaves (e.g. kicked rooms)
leaveRooms.forEach(function(leaveObj) {
// Do the bear minimum to register rejected invites / you leaving rooms
var room = leaveObj.room;
var stateEvents =
self._mapSyncEventsFormat(leaveObj.state, room);
var timelineEvents =
self._mapSyncEventsFormat(leaveObj.timeline, room);
room.addEvents(timelineEvents);
var accountDataEvents =
self._mapSyncEventsFormat(leaveObj.account_data);
self._processRoomEvents(room, stateEvents, timelineEvents);
room.addAccountData(accountDataEvents);
room.recalculate(client.credentials.userId);
if (leaveObj.isBrandNewRoom) {
client.store.storeRoom(room);
client.emit("Room", room);
}
stateEvents.forEach(function(e) { client.emit("event", e); });
timelineEvents.forEach(function(e) { client.emit("event", e); });
accountDataEvents.forEach(function(e) { client.emit("event", e); });
});
};