diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index 32434b62..8357bc1d 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -99,7 +99,7 @@ export class Room extends EventEmitter { } else { let members; if (!this._summary.hasFetchedMembers) { - const paginationToken = throw new Error("not implemented"); + const paginationToken = this._summary.lastPaginationToken; // TODO: move all of this out of Room // if any members are changed by sync while we're fetching members, diff --git a/src/matrix/room/RoomSummary.js b/src/matrix/room/RoomSummary.js index 96eba2a8..dd443be3 100644 --- a/src/matrix/room/RoomSummary.js +++ b/src/matrix/room/RoomSummary.js @@ -27,7 +27,12 @@ function applySyncResponse(data, roomResponse, membership) { data = roomResponse.state.events.reduce(processEvent, data); } if (roomResponse.timeline) { - data = roomResponse.timeline.events.reduce(processEvent, data); + const {timeline} = roomResponse; + if (timeline.prev_batch) { + data = data.cloneIfNeeded(); + data.lastPaginationToken = timeline.prev_batch; + } + data = timeline.events.reduce(processEvent, data); } return data; @@ -99,6 +104,7 @@ class SummaryData { this.canonicalAlias = copy ? copy.canonicalAlias : null; this.altAliases = copy ? copy.altAliases : null; this.hasFetchedMembers = copy ? copy.hasFetchedMembers : false; + this.lastPaginationToken = copy ? copy.lastPaginationToken : null; this.cloned = copy ? true : false; } @@ -153,6 +159,10 @@ export class RoomSummary { return this._data.hasFetchedMembers; } + get lastPaginationToken() { + return this._data.lastPaginationToken; + } + writeHasFetchedMembers(value, txn) { const data = new SummaryData(this._data); data.hasFetchedMembers = value;