store last pagination token

This commit is contained in:
Bruno Windels 2020-08-19 16:29:08 +02:00
parent d08297d1e0
commit f84c9d51b4
2 changed files with 12 additions and 2 deletions

View File

@ -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,

View File

@ -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;