Skip to content

refactor(timeline): replace TimelineEventKind with TimelineAction #4655

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 20 commits into from
May 13, 2025

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Feb 11, 2025

This centralizes (and simplifies, IMO) the creation of new timeline items vs handling of aggregations. Before, this was done partly when creating the (type previously known as) TimelineEventKind and handling it later in the TimelineEventHandler. Now, the event is analyzed once, and analyzing the event results in three outcomes:

  • either the event type is not supported: we do nothing
  • or it would result in a new timeline item: the item is created and wrapped in TimelineAction::AddItem
  • or it would result in a new aggregation: the aggregation is created and wrapped in TimelineAction::HandleAggregation

That way, it should be much simpler to handle aggregation-only events in non-live timelines, which will be handy for thread timelines.

Part of #4869.

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 86.91589% with 28 lines in your changes missing coverage. Please review.

Project coverage is 85.89%. Comparing base (08800f7) to head (b8469a4).
Report is 50 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk-ui/src/timeline/event_handler.rs 85.32% 27 Missing ⚠️
...dk-ui/src/timeline/controller/state_transaction.rs 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4655      +/-   ##
==========================================
+ Coverage   85.85%   85.89%   +0.04%     
==========================================
  Files         325      325              
  Lines       35855    35871      +16     
==========================================
+ Hits        30784    30813      +29     
+ Misses       5071     5058      -13     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bnjbvr bnjbvr mentioned this pull request Apr 24, 2025
19 tasks
bnjbvr added 16 commits May 12, 2025 16:11
This information can be accessed via the `TimelineMetadata::own_user_id`
field, which is instantiated only once.
Once again, this information is available in the `TimelineMetadata`.
The intent is that the `TimelineItemContent` can be constructed in a
single place, avoiding the need to create it in multiple places.
…for non-items

This variant will be used to cause side-effects to existing timeline
items, because the event they relate to is for an aggregation
(edit/reaction/etc.).

This is used here for reactions.
@bnjbvr bnjbvr force-pushed the bnjbvr/replace-timeline-event-kind branch from 1234cc7 to 0071fef Compare May 12, 2025 15:44
@bnjbvr bnjbvr changed the title refactor(timeline): replace TimelineEventKind refactor(timeline): replace TimelineEventKind with TimelineAction May 12, 2025
@bnjbvr bnjbvr force-pushed the bnjbvr/replace-timeline-event-kind branch from 0071fef to 1011700 Compare May 12, 2025 15:50
@bnjbvr bnjbvr marked this pull request as ready for review May 12, 2025 15:50
@bnjbvr bnjbvr requested a review from a team as a code owner May 12, 2025 15:50
@bnjbvr bnjbvr requested review from Hywan and removed request for a team May 12, 2025 15:50
@bnjbvr bnjbvr force-pushed the bnjbvr/replace-timeline-event-kind branch from 1011700 to 802049f Compare May 13, 2025 07:49
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.

That's a very nice refactoring. I've enjoyed reading the patches, well done. Everything is clear, and I appreciate the new state of this particular flow, it's a clear improvement. It also gently paves the road for thread support.

Thank you!

@bnjbvr bnjbvr enabled auto-merge (rebase) May 13, 2025 12:00
@bnjbvr bnjbvr merged commit ac42953 into main May 13, 2025
42 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/replace-timeline-event-kind branch May 13, 2025 12:15
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.

2 participants