Class TimelineWindow

Hierarchy

  • TimelineWindow

Constructors

  • Construct a TimelineWindow.

    This abstracts the separate timelines in a Matrix * module:models/room|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 * module:timeline-window~TimelineWindow#load|load.

    Note that the window will not automatically extend itself when new events are received from /sync; you should arrange to call * module:timeline-window~TimelineWindow#paginate|paginate on * module:client~MatrixClient.event:"Room.timeline"|Room.timeline events.

    Parameters

    • client: MatrixClient

      MatrixClient to be used for context/pagination requests.

    • timelineSet: EventTimelineSet

      The timelineSet to track

    • Optional opts: IOpts = {}

      Configuration options for this window

    Returns TimelineWindow

Properties

client: MatrixClient

MatrixClient to be used for context/pagination requests.

eventCount: number = 0
timelineSet: EventTimelineSet

The timelineSet to track

windowLimit: number

Methods

  • 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.

    Returns

    true if we can paginate in the given direction

    Parameters

    • direction: Direction

      EventTimeline.BACKWARDS to check if we can paginate backwards; EventTimeline.FORWARDS to check if we can go forwards

    Returns boolean

  • Try to extend the window using events that are already in the underlying TimelineIndex.

    Returns

    true if the window was extended, false otherwise.

    Parameters

    • direction: Direction

      EventTimeline.BACKWARDS to try extending it backwards; EventTimeline.FORWARDS to try extending it forwards.

    • size: number

      number of events to try to extend by.

    Returns boolean

  • Get the TimelineIndex of the window in the given direction.

    Returns

    The requested timeline index if one exists, null otherwise.

    Parameters

    • direction: Direction

      EventTimeline.BACKWARDS to get the TimelineIndex at the start of the window; EventTimeline.FORWARDS to get the TimelineIndex at the end.

    Returns null | TimelineIndex

  • Initialise the window to point at a given event, or the live timeline

    Returns

    Parameters

    • Optional initialEventId: string

      If given, the window will contain the given event

    • Optional initialWindowSize: number = 20

    Returns Promise<void>

  • Attempt to extend the window

    Returns

    Resolves to a boolean which is true if more events were successfully retrieved.

    Parameters

    • direction: Direction

      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.

    • Optional makeRequest: boolean = true
    • Optional requestLimit: number = DEFAULT_PAGINATE_LOOP_LIMIT

    Returns Promise<boolean>

  • Remove delta events from the start or end of the timeline.

    Parameters

    • delta: number

      number of events to remove from the timeline

    • startOfTimeline: boolean

      if events should be removed from the start of the timeline.

    Returns void

Generated using TypeDoc