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

Fix incompatibility with peeking.

The peek code needs to make sure it sets the pagination token /after/ adding
the events to the timeline, otherwise it will get reset when the events
are added.
This commit is contained in:
Richard van der Hoff
2016-01-26 11:15:46 +00:00
parent 840b8f0bc0
commit 48d1bc3158

View File

@@ -216,10 +216,6 @@ SyncApi.prototype.peek = function(roomId) {
response.messages.chunk, client.getEventMapper() response.messages.chunk, client.getEventMapper()
); );
if (response.messages.start) {
peekRoom.oldState.paginationToken = response.messages.start;
}
// set the state of the room to as it was after the timeline executes // set the state of the room to as it was after the timeline executes
peekRoom.oldState.setStateEvents(oldStateEvents); peekRoom.oldState.setStateEvents(oldStateEvents);
peekRoom.currentState.setStateEvents(stateEvents); peekRoom.currentState.setStateEvents(stateEvents);
@@ -230,6 +226,12 @@ SyncApi.prototype.peek = function(roomId) {
// roll backwards to diverge old state: // roll backwards to diverge old state:
peekRoom.addEventsToTimeline(messages.reverse(), true); 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;
}
client.store.storeRoom(peekRoom); client.store.storeRoom(peekRoom);
client.emit("Room", peekRoom); client.emit("Room", peekRoom);