Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeline: always include a first virtual item #4821

Open
4 tasks
bnjbvr opened this issue Mar 20, 2025 · 0 comments
Open
4 tasks

timeline: always include a first virtual item #4821

bnjbvr opened this issue Mar 20, 2025 · 0 comments

Comments

@bnjbvr
Copy link
Member

bnjbvr commented Mar 20, 2025

A room's timeline can be in three states:

  • we know all the events
  • we have a gap at the start of the timeline, and it is being resolved (via a pagination) right now
  • we have a gap at the start of the timeline, and it is not being resolved right now

Historically, we've let embedders add UI items to signal that they've reached the start of the timeline or not. However, this creates complications, as the app have to look at the back-pagination status and conclude from there:

  • lots of back-and-forths across the FFI layer to get this information
  • the status is triggered async while back-paginated events will be inserted async too, so there can be latency between the time we know we reached the start of the timeline, and the time events will be inserted into the timeline. (Fun race condition: events being inserted after the app decided to show the start item)
  • nasty bugs with nasty fixes

#4816 adds support for a virtual TimelineStart item, which is inserted after pagination terminates and we know we've hit the start of the timeline. This way, apps don't have to take care of it anymore.

The next steps would be to add another kind of virtual timeline item for gaps as well:

struct Gap {
  /// Whether the gap is being resolved (via a back-pagination) now
  resolving: bool,

  /// The token used for pagination, if any.
  token: Option<String>,
}

The token field will serve to distinguish, in the future, gaps from one another, would we want to display gaps in general.

But even if we don't display gaps in general, we can improve the situation by maintaining the invariant that we always have a virtual timeline item at start:

This may be used also in the context of the focused timeline, where a Gap could be inserted at the bottom/end (i.e. the most recent position) of the timeline, to indicate that there are more events to be forward-paginated.

Rough plan

  • feat(timeline): add a virtual start of timeline item #4816
  • introduce the Gap virtual item
  • live timeline: insert it at the right place, at the right time (and make sure there's either a gap or a timeline start as the first item)
  • focused timeline: insert it for backward and forward paginations too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant