Fix pagination and improve typing

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-08-18 10:02:42 +02:00
parent d5ffdf1196
commit f5cbc9f598
No known key found for this signature in database
GPG Key ID: 55C211A1226CB17D
1 changed files with 20 additions and 6 deletions

View File

@ -21,7 +21,7 @@ import { Room } from 'matrix-js-sdk/src/models/room';
import { MatrixEvent } from 'matrix-js-sdk/src/models/event';
import { EventTimelineSet } from 'matrix-js-sdk/src/models/event-timeline-set';
import { RoomState } from 'matrix-js-sdk/src/models/room-state';
import { TimelineWindow } from 'matrix-js-sdk/src/timeline-window';
import { TimelineIndex, TimelineWindow } from 'matrix-js-sdk/src/timeline-window';
import { sleep } from "matrix-js-sdk/src/utils";
import { IResultRoomEvents } from "matrix-js-sdk/src/@types/search";
@ -859,13 +859,27 @@ export default class EventIndex extends EventEmitter {
return Promise.resolve(true);
}
const paginationMethod = async (timelineWindow, timeline, room, direction, limit) => {
const timelineSet = timelineWindow._timelineSet;
const token = timeline.timeline.getPaginationToken(direction);
const paginationMethod = async (
timelineWindow: TimelineWindow,
timelineIndex: TimelineIndex,
room: Room,
direction: Direction,
limit: number,
) => {
const timeline = timelineIndex.timeline;
const timelineSet = timeline.getTimelineSet();
const token = timeline.getPaginationToken(direction);
const ret = await this.populateFileTimeline(timelineSet, timeline.timeline, room, limit, token, direction);
const ret = await this.populateFileTimeline(
timelineSet,
timeline,
room,
limit,
token,
direction,
);
timeline.pendingPaginate = null;
timelineIndex.pendingPaginate = null;
timelineWindow.extend(direction, limit);
return ret;