From f5cbc9f598119f5283fd120d13c496a46732ce3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 18 Aug 2021 10:02:42 +0200 Subject: [PATCH] Fix pagination and improve typing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/indexing/EventIndex.ts | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/indexing/EventIndex.ts b/src/indexing/EventIndex.ts index a7142010f23..e3deb7510dd 100644 --- a/src/indexing/EventIndex.ts +++ b/src/indexing/EventIndex.ts @@ -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 ret = await this.populateFileTimeline(timelineSet, timeline.timeline, room, limit, token, 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, + room, + limit, + token, + direction, + ); - timeline.pendingPaginate = null; + timelineIndex.pendingPaginate = null; timelineWindow.extend(direction, limit); return ret;