1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Address a number of review comments.

Make sure that room state is copied correctly when resetting the live
timeline.

Also comments and bits.
This commit is contained in:
Richard van der Hoff
2016-01-26 18:09:15 +00:00
parent 48d1bc3158
commit a01501b42c
5 changed files with 178 additions and 92 deletions

View File

@@ -216,6 +216,13 @@ SyncApi.prototype.peek = function(roomId) {
response.messages.chunk, client.getEventMapper()
);
// set the pagination token before adding the events in case people
// fire off pagination requests in response to the Room.timeline
// events.
if (response.messages.start) {
peekRoom.oldState.paginationToken = response.messages.start;
}
// set the state of the room to as it was after the timeline executes
peekRoom.oldState.setStateEvents(oldStateEvents);
peekRoom.currentState.setStateEvents(stateEvents);
@@ -223,14 +230,11 @@ SyncApi.prototype.peek = function(roomId) {
self._resolveInvites(peekRoom);
peekRoom.recalculate(self.client.credentials.userId);
// roll backwards to diverge old state:
peekRoom.addEventsToTimeline(messages.reverse(), true);
// set the pagination token. Make sure this happens after adding
// events to the timeline, otherwise it will get reset.
if (response.messages.start) {
peekRoom.oldState.paginationToken = response.messages.start;
}
// roll backwards to diverge old state. addEventsToTimeline
// will overwrite the pagination token, so make sure it overwrites
// it with the right thing.
peekRoom.addEventsToTimeline(messages.reverse(), true,
undefined, response.messages.start);
client.store.storeRoom(peekRoom);
client.emit("Room", peekRoom);