import { Direction, EventTimeline } from "./models/event-timeline"; import { MatrixClient } from "./client"; import { EventTimelineSet } from "./models/event-timeline-set"; import { MatrixEvent } from "./models/event"; interface IOpts { /** * Maximum number of events to keep in the window. If more events are retrieved via pagination requests, * excess events will be dropped from the other end of the window. */ windowLimit?: number; } export declare class TimelineWindow { private readonly client; private readonly timelineSet; private readonly windowLimit; private start?; private end?; private eventCount; /** * Construct a TimelineWindow. * *
This abstracts the separate timelines in a Matrix {@link Room} into a single iterable thing. * It keeps track of the start and endpoints of the window, which can be advanced with the help * of pagination requests. * *
Before the window is useful, it must be initialised by calling {@link TimelineWindow#load}. * *
Note that the window will not automatically extend itself when new events
* are received from /sync; you should arrange to call {@link TimelineWindow#paginate}
* on {@link RoomEvent.Timeline} events.
*
* @param client - MatrixClient to be used for context/pagination
* requests.
*
* @param timelineSet - The timelineSet to track
*
* @param opts - Configuration options for this window
*/
constructor(client: MatrixClient, timelineSet: EventTimelineSet, opts?: IOpts);
/**
* Initialise the window to point at a given event, or the live timeline
*
* @param initialEventId - If given, the window will contain the
* given event
* @param initialWindowSize - Size of the initial window
*/
load(initialEventId?: string, initialWindowSize?: number): Promise This returns true if we either have more events, or if we have a
* pagination token which means we can paginate in that direction. It does not
* necessarily mean that there are more events available in that direction at
* this time.
*
* @param direction - EventTimeline.BACKWARDS to check if we can
* paginate backwards; EventTimeline.FORWARDS to check if we can go forwards
*
* @returns true if we can paginate in the given direction
*/
canPaginate(direction: Direction): boolean;
/**
* Attempt to extend the window
*
* @param direction - EventTimeline.BACKWARDS to extend the window
* backwards (towards older events); EventTimeline.FORWARDS to go forwards.
*
* @param size - number of events to try to extend by. If fewer than this
* number are immediately available, then we return immediately rather than
* making an API call.
*
* @param makeRequest - whether we should make API calls to
* fetch further events if we don't have any at all. (This has no effect if
* the room already knows about additional events in the relevant direction,
* even if there are fewer than 'size' of them, as we will just return those
* we already know about.)
*
* @param requestLimit - limit for the number of API requests we
* should make.
*
* @returns Promise which resolves to a boolean which is true if more events
* were successfully retrieved.
*/
paginate(direction: Direction, size: number, makeRequest?: boolean, requestLimit?: number): Promise