Class: TimelineWindow

timeline-window~TimelineWindow

new TimelineWindow(client, timelineSet, optsopt)

Construct a TimelineWindow.

This abstracts the separate timelines in a Matrix 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 load.

Note that the window will not automatically extend itself when new events are received from /sync; you should arrange to call paginate on Room.timeline events.

Parameters:
Name Type Attributes Description
client MatrixClient MatrixClient to be used for context/pagination requests.
timelineSet EventTimelineSet The timelineSet to track
opts Object <optional>
Configuration options for this window
Properties
Name Type Attributes Default Description
windowLimit number <optional>
1000 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.
Source:

Methods

canPaginate(direction) → {boolean}

Check if this window can be extended

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.

Parameters:
Name Type Description
direction string EventTimeline.BACKWARDS to check if we can paginate backwards; EventTimeline.FORWARDS to check if we can go forwards
Source:
Returns:
true if we can paginate in the given direction
Type
boolean

getEvents() → {Array.<MatrixEvent>}

Get a list of the events currently in the window
Source:
Returns:
the events in the window
Type
Array.<MatrixEvent>

load(initialEventIdopt, initialWindowSizeopt) → {module:client.Promise}

Initialise the window to point at a given event, or the live timeline
Parameters:
Name Type Attributes Default Description
initialEventId string <optional>
If given, the window will contain the given event
initialWindowSize number <optional>
20 Size of the initial window
Source:
Returns:
Type
module:client.Promise

paginate(direction, size, makeRequestopt, requestLimitopt) → {module:client.Promise}

Attempt to extend the window
Parameters:
Name Type Attributes Default Description
direction string EventTimeline.BACKWARDS to extend the window backwards (towards older events); EventTimeline.FORWARDS to go forwards.
size number 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.
makeRequest boolean <optional>
true 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.)
requestLimit number <optional>
5 limit for the number of API requests we should make.
Source:
Returns:
Resolves to a boolean which is true if more events were successfully retrieved.
Type
module:client.Promise