This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/src/matrix/room/timeline
2022-07-04 16:59:17 +02:00
..
entries split up create code into separate files 2022-02-10 16:43:32 +01:00
persistence Merge branch 'master' into bwindels/calls 2022-07-04 16:59:17 +02:00
common.js Refactor + put redaction in NonPersistedEventEntry 2022-01-07 19:38:57 +05:30
Direction.ts convert Direction to ts 2021-09-06 13:06:20 +02:00
EventKey.ts turns out we do write these 2021-09-06 13:10:36 +02:00
FragmentIdComparer.js WIP 2021-08-04 15:23:03 +02:00
PendingAnnotation.js use pending re(d)action timestamp to have stable reaction sorting order 2021-06-24 12:26:38 +02:00
README.md add basic readme for updates in the timeline 2022-01-14 11:13:21 +01:00
relations.js split up create code into separate files 2022-02-10 16:43:32 +01:00
Timeline.js fix observable typescript errors 2022-04-25 14:05:02 +02:00

Timeline

Nomenclature

  • Entry: an element that can be part of the timeline. This is either an event or a gap. When they are part of the timeline, entries are sorted by their fragmentId first, then their event index.
  • Tile: a view model around one or more entries. A tile will be rendered by one view.

How are timeline updates propagated?

Most timeline updates are caused by either sync or a gap fill. These happen in Room and will call Timeline.addEntries for now entries and Timeline.replaceEntries for entries that where previously known to Hydrogen and received some kind of update. They may or may not have been loaded into the timeline already. Examples of what causes an update is: a relation was added to the target event, the event was redacted, the event was decrypted where it couldn't be before, ...

Also events that haven't been sent yet are shown in the timeline, always below the remote messages. These updates are triggered in SendQueue and passed through the pendingEvents observable list.

Timeline exposes an observable list with all (sorted) entries under the entries property. Additions, updates and removals are emitted over this collection, once subscribed.

Context entries

Some messages in the timeline require another message to be able to display themselves. The only example of this currently is replies. When an entry is added to the timeline, it's contextEventId property will be checked. If it returns an id, we'll try to get the matching entry, either from the loaded messages, storage or the /context endpoint from the server.

Note that /context entries are not stored because currently it is not possible to detect overlap between timeline fragments created by sync and fragments created by /context, and storing events presumes it will be in a fragment. This means they can't be updated by the relation writer, as it assumes an entry is in storage. Hence for relation and redaction support, we reuse the local echo infrastructure (entry.addLocalRelation()) used already for pending events.

When the context entry is updated through replaceEntries, an update event will also be emitted for every entry in the timeline that uses the updated entry as context. An example is when a replied-to message is redacted, the reply entry will also emit an update.