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

day dividers: don't assume a previous item is at the immediate previous position #3273

Merged
merged 3 commits into from
Mar 25, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Mar 25, 2024

When removing or replacing a previous item that was a day divider, we assumed it was always at the immediate previous position (i - 1 in the loop). That's not correct, because there could be other items unrelated to the day divider algorithm in between (like a read marker), so it would fail the previous assertion.

The regression test (that fails on current main) shows the required setup:

  1. event @ ts X
  2. day divider @ ts X+1day
  3. read marker
  4. event @ ts X

When seeing the event, we decided to remove the "previous" day divider that was spurious, and assumed it was at position 2, while it was at position 1. The solution is to keep track of the actual index of the previous item, in addition to the previous item itself.

Also, I've lowered the severity of the check, from an assertion to an tracing::error! statement, so that we can still see it in logs, but it's not preventing the timeline to update. It was a bit harsh to do so.

bnjbvr added 2 commits March 25, 2024 12:08
…ious position

There could be situations where we have a day divider, then a read marker, then an event. In that case, when looking at the event, if the previous day divider is wrong and needs
to be removed, we would assume the "previous item" (= the day divider) was at position i-1, which could be that of the read marker, and we'd remove the read marker instead of the
day divider.
It's not worth panic'ing the whole timeline because we removed the wrong item; worst case, users will complain and can send a rageshake that contains all the information that's
needed to debug what went wrong.
@bnjbvr bnjbvr requested a review from a team as a code owner March 25, 2024 11:47
@bnjbvr bnjbvr requested review from Hywan and removed request for a team March 25, 2024 11:47
@bnjbvr bnjbvr force-pushed the fix-daydivider-readmarker branch from 4bd0858 to 36b55b1 Compare March 25, 2024 11:48
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, thanks for the investigation and the fix!

@bnjbvr bnjbvr enabled auto-merge (rebase) March 25, 2024 11:54
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

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

Project coverage is 83.62%. Comparing base (95a471b) to head (36b55b1).

Files Patch % Lines
crates/matrix-sdk-ui/src/timeline/day_dividers.rs 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3273      +/-   ##
==========================================
- Coverage   83.62%   83.62%   -0.01%     
==========================================
  Files         239      239              
  Lines       24705    24707       +2     
==========================================
  Hits        20660    20660              
- Misses       4045     4047       +2     

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

@bnjbvr bnjbvr merged commit baac38f into main Mar 25, 2024
35 checks passed
@bnjbvr bnjbvr deleted the fix-daydivider-readmarker branch March 25, 2024 13:48
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