Skip to content

timeline: add event focus mode for permalinks #3329

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

Merged
merged 4 commits into from
Apr 25, 2024
Merged

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Apr 15, 2024

Fixes #3234.

See the commit message of the first commit for more details. This is sufficient to implement pagination in the timeline.

@bnjbvr bnjbvr force-pushed the bnjbvr/permalink-mvp branch from c6a32d3 to 96e1f4f Compare April 19, 2024 15:55
@bnjbvr bnjbvr force-pushed the bnjbvr/permalink-mvp branch 2 times, most recently from 0c95063 to fd6e21e Compare April 23, 2024 16:46
@bnjbvr bnjbvr marked this pull request as ready for review April 23, 2024 16:47
@bnjbvr bnjbvr requested a review from a team as a code owner April 23, 2024 16:47
@bnjbvr bnjbvr requested review from Hywan and removed request for a team April 23, 2024 16:47
bnjbvr added 3 commits April 23, 2024 19:02
This introduces the `TimelineFocus`, a new enum to declare if the
timeline is "live" aka looking at events from sync and displaying them
as they come in, or focused on an event (e.g. after clicking a
permalink).

When in the second mode, the timeline can paginate forwards and
backwards, without interacting with the event cache (as this would
require some complicated reconciliation of known events with events
received from pagination, with no guarantee that those events are event
connected in whatever way).

An event-focused timeline will also show edits/reactions/redactions in
real-time (as the events are received from the sync), but will not show
new timeline items, be they for local echoes or events received from the
sync.
Copy link

codecov bot commented Apr 23, 2024

Codecov Report

Attention: Patch coverage is 85.84071% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 83.64%. Comparing base (4156170) to head (25f893b).

Files Patch % Lines
crates/matrix-sdk-ui/src/timeline/inner/mod.rs 83.92% 9 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/event_handler.rs 77.77% 4 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/builder.rs 93.75% 1 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/mod.rs 66.66% 1 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/pagination.rs 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3329      +/-   ##
==========================================
+ Coverage   83.63%   83.64%   +0.01%     
==========================================
  Files         242      242              
  Lines       24939    25016      +77     
==========================================
+ Hits        20857    20924      +67     
- Misses       4082     4092      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work, well done!

let (events, mut event_subscriber) = room_event_cache.subscribe().await?;

let has_events = !events.is_empty();
let (_, mut event_subscriber) = room_event_cache.subscribe().await?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we explain why we drop events here?

///
/// Returns whether we hit the end of the timeline.
#[instrument(skip_all)]
pub async fn focused_paginate_forwards(&self, num_events: u16) -> Result<bool, Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to keep this method private?

///
/// Returns whether we hit the start of the timeline.
#[instrument(skip(self), fields(room_id = ?self.room().room_id()))]
pub async fn focused_paginate_backwards(&self, num_events: u16) -> Result<bool, Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to keep this method private?

#[instrument(skip_all, fields(room_id = ?self.room().room_id(), ?options))]
pub async fn paginate_backwards(
pub async fn live_paginate_backwards(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this renaming is necessary.

///
/// Returns whether we hit the end of the timeline or not.
pub async fn paginate_forwards(&self, num_events: u16) -> Result<bool, ClientError> {
Ok(self.inner.focused_paginate_forwards(num_events).await?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be simply paginate_forwards?

@Hywan Hywan self-assigned this Apr 25, 2024
@Hywan
Copy link
Member

Hywan commented Apr 25, 2024

Actually, there is a problem with the pagination code:

  1. it is duplicated with the code inside event_cache::paginator, or at least partially
  2. it creates another duplication to handle the pagination status.

Finally, there is another problem:

  1. if the pagination is cancelled, the status is not reset, thus forbidding it to re-run properly; for example, if the status is Paginating, the pagination won't run; problem is: the status is reset after the pagination is done, it's set to Idle, but if the method is cancelled before reaching the Idle status, it will in Paginating forever.

@Hywan Hywan enabled auto-merge April 25, 2024 14:14
@Hywan Hywan merged commit dddc607 into main Apr 25, 2024
35 checks passed
@Hywan Hywan deleted the bnjbvr/permalink-mvp branch April 25, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pin the timeline to a given event and paginate all the directions (permalink)
2 participants