Bug 1705473 - Use matrix SDK TimelineWindow for pagination. r=clokep
Differential Revision: https://phabricator.services.mozilla.com/D112236
This commit is contained in:
Родитель
c7770c0606
Коммит
fa8995b452
|
@ -304,38 +304,30 @@ var GenericMatrixConversation = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get the timeline for the event, or just the current live timeline of the room
|
// Get the timeline for the event, or just the current live timeline of the room
|
||||||
let timeline;
|
let timelineWindow = new MatrixSDK.TimelineWindow(
|
||||||
if (latestOldEvent) {
|
this._account._client,
|
||||||
timeline = this.room.getTimelineForEvent(latestOldEvent);
|
this.room.getUnfilteredTimelineSet()
|
||||||
// The event wasn't in our local cache yet, let's start a timeline containing the event
|
);
|
||||||
if (!timeline) {
|
const windowChunkSize = 100;
|
||||||
await this._account._client.getEventTimeline(
|
await timelineWindow.load(latestOldEvent, windowChunkSize);
|
||||||
this.room.getUnfilteredTimelineSet(),
|
// Remove the old event from the window.
|
||||||
latestOldEvent
|
timelineWindow.unpaginate(1, true);
|
||||||
);
|
let newEvents = timelineWindow.getEvents();
|
||||||
timeline = this.room.getTimelineForEvent(latestOldEvent);
|
for (const event of newEvents) {
|
||||||
}
|
this.addEvent(event, true);
|
||||||
} else {
|
|
||||||
timeline = this.room.getLiveTimeline();
|
|
||||||
}
|
}
|
||||||
if (timeline) {
|
while (timelineWindow.canPaginate(EventTimeline.FORWARDS)) {
|
||||||
// Make sure the timeline cotains all events up to the present
|
if (
|
||||||
let timelineCatchingUp = true;
|
await timelineWindow.paginate(EventTimeline.FORWARDS, windowChunkSize)
|
||||||
while (timelineCatchingUp) {
|
) {
|
||||||
timelineCatchingUp = await this._account._client.paginateEventTimeline(
|
timelineWindow.unpaginate(newEvents.length, true);
|
||||||
timeline
|
newEvents = timelineWindow.getEvents();
|
||||||
);
|
for (const event of newEvents) {
|
||||||
}
|
|
||||||
// Write all new events to the conversation
|
|
||||||
const events = timeline.getEvents();
|
|
||||||
let pastLatestOldEvent = !latestOldEvent;
|
|
||||||
for (const event of events) {
|
|
||||||
if (pastLatestOldEvent) {
|
|
||||||
this.addEvent(event, true);
|
this.addEvent(event, true);
|
||||||
}
|
}
|
||||||
if (!pastLatestOldEvent && event.getId() === latestOldEvent) {
|
} else {
|
||||||
pastLatestOldEvent = true;
|
// Pagination was unable to add any more events
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче