Class EventTimeline

Constructors

  • Construct a new EventTimeline

    An EventTimeline represents a contiguous sequence of events in a room.

    As well as keeping track of the events themselves, it stores the state of the room at the beginning and end of the timeline, and pagination tokens for going backwards and forwards in the timeline.

    In order that clients can meaningfully maintain an index into a timeline, the EventTimeline object tracks a 'baseIndex'. This starts at zero, but is incremented when events are prepended to the timeline. The index of an event relative to baseIndex therefore remains constant.

    Once a timeline joins up with its neighbour, they are linked together into a doubly-linked list.

    Parameters

    Returns EventTimeline

Properties

baseIndex: number = 0
endState?: RoomState
endToken: null | string = null
eventTimelineSet: EventTimelineSet

the set of timelines this is part of

events: MatrixEvent[] = []
name: string
nextTimeline: null | EventTimeline = null
paginationRequests: Record<Direction, null | Promise<boolean>> = ...
prevTimeline: null | EventTimeline = null
roomId: null | string
startState?: RoomState
startToken: null | string = null
BACKWARDS: Backward = Direction.Backward

Symbolic constant for methods which take a 'direction' argument: refers to the start of the timeline, or backwards in time.

FORWARDS: Forward = Direction.Forward

Symbolic constant for methods which take a 'direction' argument: refers to the end of the timeline, or forwards in time.

Methods

  • Creates an independent timeline, inheriting the directional state from this timeline.

    Parameters

    • direction: Direction

      EventTimeline.BACKWARDS to get the state at the start of the timeline; EventTimeline.FORWARDS to get the state at the end of the timeline.

    Returns EventTimeline

    the new timeline

  • Forks the (live) timeline, taking ownership of the existing directional state of this timeline. All attached listeners will keep receiving state updates from the new live timeline state. The end state of this timeline gets replaced with an independent copy of the current RoomState, and will need a new pagination token if it ever needs to paginate forwards.

    Parameters

    • direction: Direction

      EventTimeline.BACKWARDS to get the state at the start of the timeline; EventTimeline.FORWARDS to get the state at the end of the timeline.

    Returns EventTimeline

    the new timeline

  • Get the base index.

    This is an index which is incremented when events are prepended to the timeline. An individual event therefore stays at the same index in the array relative to the base index (although note that a given event's index may well be less than the base index, thus giving that event a negative relative index).

    Returns number

  • Get the next timeline in the series

    Parameters

    • direction: Direction

      EventTimeline.BACKWARDS to get the previous timeline; EventTimeline.FORWARDS to get the next timeline.

    Returns null | EventTimeline

    previous or following timeline, if they have been joined up.

  • Get a pagination token

    Parameters

    • direction: Direction

      EventTimeline.BACKWARDS to get the pagination token for going backwards in time; EventTimeline.FORWARDS to get the pagination token for going forwards in time.

    Returns null | string

    pagination token

  • Get the room state at the start/end of the timeline

    Parameters

    • direction: Direction

      EventTimeline.BACKWARDS to get the state at the start of the timeline; EventTimeline.FORWARDS to get the state at the end of the timeline.

    Returns undefined | RoomState

    state at the start/end of the timeline

  • Initialise the start and end state with the given events

    This can only be called before any events are added.

    Parameters

    Returns void

    Throws

    Error if an attempt is made to call this after addEvent is called.

  • Internal

    Insert a new event into the timeline, and update the state.

    TEMPORARY: until we have recursive relations, we need this function to exist to allow us to insert events in timeline order, which is our best guess for Sync Order. This is a copy of addEvent above, modified to allow inserting an event at a specific index.

    Parameters

    Returns void

  • Set the next timeline in the series

    Parameters

    • neighbour: EventTimeline

      previous/following timeline

    • direction: Direction

      EventTimeline.BACKWARDS to set the previous timeline; EventTimeline.FORWARDS to set the next timeline.

    Returns void

    Throws

    Error if an attempt is made to set the neighbouring timeline when it is already set.

  • Set a pagination token

    Parameters

    • token: null | string

      pagination token

    • direction: Direction

      EventTimeline.BACKWARDS to set the pagination token for going backwards in time; EventTimeline.FORWARDS to set the pagination token for going forwards in time.

    Returns void

  • Static helper method to set sender and target properties

    Parameters

    • event: MatrixEvent

      the event whose metadata is to be set

    • stateContext: RoomState

      the room state to be queried

    • toStartOfTimeline: boolean

      if true the event's forwardLooking flag is set false

    Returns void

Generated using TypeDoc