You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +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:
10
lib/sync.js
10
lib/sync.js
@@ -216,10 +216,6 @@ SyncApi.prototype.peek = function(roomId) {
|
||||
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
|
||||
peekRoom.oldState.setStateEvents(oldStateEvents);
|
||||
peekRoom.currentState.setStateEvents(stateEvents);
|
||||
@@ -230,6 +226,12 @@ SyncApi.prototype.peek = function(roomId) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
client.store.storeRoom(peekRoom);
|
||||
client.emit("Room", peekRoom);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user