Class EventTimelineSet

Typed Event Emitter class which can act as a Base Model for all our model and communication events. This makes it much easier for us to distinguish between events, as we now need to properly type this, so that our events are not stringly-based and prone to silly typos.

Hierarchy

Constructors

  • Construct a set of EventTimeline objects, typically on behalf of a given room. A room may have multiple EventTimelineSets for different levels of filtering. The global notification list is also an EventTimelineSet, but lacks a room.

    This is an ordered sequence of timelines, which may or may not be continuous. Each timeline lists a series of events, as well as tracking the room state at the start and the end of the timeline (if appropriate). It also tracks forward and backward pagination tokens, as well as containing links to the next timeline in the sequence.

    There is one special timeline - the 'live' timeline, which represents the timeline to which events are being added in real-time as they are received from the /sync API. Note that you should not retain references to this timeline - even if it is the current timeline right now, it may not remain so if the server gives us a timeline gap in /sync.

    In order that we can find events from their ids later, we also maintain a map from event_id to timeline and index.

    Parameters

    • room: undefined | Room

      Room for this timelineSet. May be null for non-room cases, such as the notification timeline.

    • opts: IOpts = {}

      Options inherited from Room.

    • Optional client: MatrixClient

      the Matrix client which owns this EventTimelineSet, can be omitted if room is specified.

    • Optional thread: Thread

      the thread to which this timeline set relates.

    • threadListType: null | ThreadFilterType = null

    Returns EventTimelineSet

Properties

_eventIdToTimeline: Map<string, EventTimeline> = ...
displayPendingEvents: boolean
filter?: Filter
liveTimeline: EventTimeline
room: undefined | Room

Room for this timelineSet. May be null for non-room cases, such as the notification timeline.

thread?: Thread

the thread to which this timeline set relates.

threadListType: null | ThreadFilterType = null
timelineSupport: boolean
timelines: EventTimeline[]

Methods

  • Add events to a timeline

    Will fire "Room.timeline" for each event added.

    Fires

    module:client~MatrixClient#event:"Room.timeline"

    Parameters

    • events: MatrixEvent[]

      A list of events to add.

    • toStartOfTimeline: boolean

      True to add these events to the start (oldest) instead of the end (newest) of the timeline. If true, the oldest event will be the last element of 'events'.

    • timeline: EventTimeline

      timeline to add events to.

    • Optional paginationToken: null | string

      token for the next batch of events

    Returns void

  • Determine whether a given event can sanely be added to this event timeline set, for timeline sets relating to a thread, only return true for events in the same thread timeline, for timeline sets not relating to a thread only return true for events which should be shown in the main room timeline. Requires the room property to have been set at EventTimelineSet construction time.

    Throws

    if room was not set when constructing this timeline set.

    Returns

    whether the event belongs to this timeline set.

    Parameters

    • event: MatrixEvent

      {MatrixEvent} the event to check whether it belongs to this timeline set.

    Returns boolean

  • Determine where two events appear in the timeline relative to one another

    Returns

    a number less than zero if eventId1 precedes eventId2, and greater than zero if eventId1 succeeds eventId2. zero if they are the same event; null if we can't tell (either because we don't know about one of the events, or because they are in separate timelines which don't join up).

    Parameters

    • eventId1: string

      The id of the first event

    • eventId2: string

      The id of the second event

    Returns null | number

  • Get the list of pending sent events for this timelineSet's room, filtered by the timelineSet's filter if appropriate.

    Returns

    A list of the sent events waiting for remote echo.

    Throws

    If opts.pendingEventOrdering was not 'detached'

    Returns MatrixEvent[]

  • Get the timeline which contains the given event, if any

    Returns

    timeline containing the given event, or null if unknown

    Parameters

    • Optional eventId: string

      event ID to look for

    Returns null | EventTimeline

  • Replaces event with ID oldEventId with one with newEventId, if oldEventId is recognised. Otherwise, add to the live timeline. Used to handle remote echos.

    Fires

    module:client~MatrixClient#event:"Room.timeline"

    Parameters

    • localEvent: MatrixEvent

      the new event to be added to the timeline

    • oldEventId: string

      the ID of the original event

    • newEventId: string

      the ID of the replacement event

    Returns void

  • Removes a single event from this room.

    Returns

    the removed event, or null if the event was not found in this room.

    Parameters

    • eventId: string

      The id of the event to remove

    Returns null | MatrixEvent

  • Track a new event as if it were in the same timeline as an old event, replacing it.

    Parameters

    • oldEventId: string

      event ID of the original event

    • newEventId: string

      event ID of the replacement event

    Returns void

  • Reset the live timeline, and start a new one.

    This is used when /sync returns a 'limited' timeline.

    Fires

    module:client~MatrixClient#event:"Room.timelineReset"

    Parameters

    • Optional backPaginationToken: string

      token for back-paginating the new timeline

    • Optional forwardPaginationToken: string

      token for forward-paginating the old live timeline, if absent or null, all timelines are reset.

    Returns void

  • Set the filter object this timeline set is filtered on (passed to the server when paginating via /messages).

    Parameters

    • Optional filter: Filter

      the filter for this timelineSet

    Returns void

Generated using TypeDoc