Timeline

interface Timeline

A Timeline instance represents a contiguous sequence of events in a room.

There are two kinds of timeline:

- live timelines: they process live events from the sync. You can paginate backwards but not forwards.

- past timelines: they start in the past from an `initialEventId`. You can paginate backwards and forwards.

Types

Link copied to clipboard
enum Direction : Enum<Timeline.Direction>

This is used to paginate in one or another direction.

Link copied to clipboard
interface Listener
Link copied to clipboard
data class PaginationState(    val hasMoreToLoad: Boolean = true,     val loading: Boolean = false,     val inError: Boolean = false)

Pagination state.

Functions

Link copied to clipboard
abstract fun addListener(listener: Timeline.Listener): Boolean
Link copied to clipboard
abstract suspend fun awaitPaginate(direction: Timeline.Direction, count: Int): List<TimelineEvent>

This is the same than the regular paginate method but waits for the results instead of relying on the timeline listener.

Link copied to clipboard
abstract fun dispose()

This must be called when you don't need the timeline. It ensures the underlying database get closed.

Link copied to clipboard
abstract fun getIndexOfEvent(eventId: String?): Int?

Returns the index of a built event or null.

Link copied to clipboard
abstract fun getPaginationState(direction: Timeline.Direction): Timeline.PaginationState

Returns the current pagination state for the direction.

Link copied to clipboard
abstract fun getSnapshot(): List<TimelineEvent>

Returns a snapshot of the timeline in his current state.

Link copied to clipboard
abstract fun hasMoreToLoad(direction: Timeline.Direction): Boolean

Check if the timeline can be enriched by paginating.

Link copied to clipboard
abstract fun paginate(direction: Timeline.Direction, count: Int)

This is the main method to enrich the timeline with new data. It will call the onTimelineUpdated method from Listener when the data will be processed. It also ensures only one pagination by direction is launched at a time, so you can safely call this multiple time in a row.

Link copied to clipboard
abstract fun removeAllListeners()
Link copied to clipboard
abstract fun removeListener(listener: Timeline.Listener): Boolean
Link copied to clipboard
abstract fun restartWithEventId(eventId: String?)

This method restarts the timeline, erases all built events and pagination states. It then loads events around the eventId. If eventId is null, it does restart the live timeline.

Link copied to clipboard
abstract fun start(rootThreadEventId: String? = null)

This must be called before any other method after creating the timeline. It ensures the underlying database is open

Properties

Link copied to clipboard
abstract val isLive: Boolean
Link copied to clipboard
abstract val timelineID: String