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

fix(ui): Change the behaviour when a duplicated event is received by the Timeline #3550

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Jun 13, 2024

This patch changes the behaviour of the Timeline when a duplicated event is received. Prior to this patch, the old event was removed, and the one was added. With this patch, the old event is kept, and the new one is skipped.

This is important for #3512 where events are mapped to the timeline item indices. When an event is removed, it becomes difficult to keep the mapping correct.

This patch also adds duplication detection for pagination (with TimelineItemPosition::Start).


…`Timeline`.

This patch changes the behaviour of the `Timeline` when a duplicated
event is received. Prior to this patch, the old event was removed, and
the one was added. With this patch, the old event is kept, and the new
one is skipped.

This is important for matrix-org#3512
where events are mapped to the timeline item indices. When an event is
removed, it becomes difficult to keep the mapping correct.

This patch also adds duplication detection for pagination (with
`TimelineItemPosition::Start`).
@Hywan Hywan requested a review from a team as a code owner June 13, 2024 12:11
@Hywan Hywan requested review from poljar and bnjbvr and removed request for a team and poljar June 13, 2024 12:11
@Hywan Hywan mentioned this pull request Jun 13, 2024
23 tasks
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Cool! And it's even tested, nice!

crates/matrix-sdk-ui/src/timeline/inner/state.rs Outdated Show resolved Hide resolved
…vent`.

This patch renames `add_event` to `add_or_update_event` because it is
what it does.
@Hywan Hywan enabled auto-merge June 13, 2024 12:23
@Hywan
Copy link
Member Author

Hywan commented Jun 13, 2024

We have many tests that play with duplicated events. Only one is breaking, the others are more high-level and we don't really see the result of this patch. However, if we try to remove the duplication check, or do it differently, many test will break. That's good.

Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.82%. Comparing base (f770248) to head (d46e658).
Report is 4 commits behind head on main.

Files Patch % Lines
crates/matrix-sdk-ui/src/timeline/inner/state.rs 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3550      +/-   ##
==========================================
- Coverage   83.84%   83.82%   -0.03%     
==========================================
  Files         254      254              
  Lines       25842    25853      +11     
==========================================
+ Hits        21668    21671       +3     
- Misses       4174     4182       +8     

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

@Hywan Hywan merged commit 868e821 into matrix-org:main Jun 13, 2024
38 checks passed
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