matrix-org / matrix-org/matrix-rust-sdk
timeline(moonshot): consider a sparse events-only timeline
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 500
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 106
Description
Right now, our timeline items can either relate to an event item (representing a matrix event), or be virtual (e.g. a date divider, the start of the timeline, the read marker, etc.).
On the other hand, the event cache only knows about events as a linearized, array representation of a Matrix room.
Because of this divide, indices into the event cache array don't match those of the timeline items, leading to some complications: every time we insert an event item into the timeline, we need to maintain a mapping of event index -> timeline item index. That's not the end of the world, but it causes some overhead, both at runtime and in terms of complexity.
A crazy idea we had would be to have an events-only timeline, where the items 1:1 match the events from the event cache array:
- aggregation events (reactions/edits/etc) could be filtered out *at the output* of the timeline subscription stream, or could be rendered as 0px high items in UIs
- all the current virtual items would be passed as an extra stream of "insert/remove" commands (e.g. "insert date divider for this given date before this given item"). In fact, that's already how the date divider algorithm works, by computing a diff of such commands, and then applying them onto the timeline items. It would be relatively simple to do the same for other virtual items.
Doing this would have one clear benefit: not having to maintain the event-cache-to-timeline-item index mapping. On the other hand, the complexity introduced by the second bullet item above may turn this into a more complicated outcome than the current state. So there's a bit of risk here, and it might be interesting experimenting with such a project.
Contributor guide
Research direction
Start by reading the timeline and event-cache implementations, then trace the timeline subscription stream and the existing date-divider diff algorithm. Determine whether an events-only timeline can handle aggregation events and virtual-item insert/remove commands without adding more complexity than the current index mapping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100