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): Fix latest_edit_json for live edits #4552

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zecakeh
Copy link
Collaborator

@zecakeh zecakeh commented Jan 18, 2025

This was a regression introduced in f0d9860.

latest_edit_json was first set by the call to EventTimelineItem::with_content(). It was overwritten in the next section because of the if let EventTimelineItemKind::Remote(remote_event) that uses item instead of new_item.
It means that the updated RemoteEventTimelineItem insidenew_item was replaced by the outdated one inside item, so latest_edit_json went back to its previous value.

I believe that part of why that went unnoticed is that the code looks more complicated due to the need to set an inner field dependant on an enum variant, so I decided to change the API and move with_encryption_info to EventTimelineItem, which makes the code look cleaner.

The changes in the tests fail without this commit.

@zecakeh zecakeh requested a review from a team as a code owner January 18, 2025 17:50
@zecakeh zecakeh requested review from Hywan and removed request for a team January 18, 2025 17:50
@zecakeh zecakeh changed the title fix(ui): Fix latest_edit_json for live messages fix(ui): Fix latest_edit_json for live edits Jan 18, 2025
@zecakeh zecakeh force-pushed the fix-live-edit-json branch from c3c436c to a23393b Compare January 18, 2025 17:55
This was a regression introduced in
f0d9860.

`latest_edit_json` was first set by the call to
`EventTimelineItem::with_content()`.
It was overwritten in the next section because of the
`if let EventTimelineItemKind::Remote(remote_event)`
that uses `item` instead of `new_item`.
It means that the updated `RemoteEventTimelineItem`
inside`new_item` was replaced by the outdated one inside `item`,
so `latest_edit_json` goes back to its previous value.

I believe that part of why that went unnoticed is that the code looks
more
complicated due to the need to set an inner field, so I decided to
change the API and
move `with_encryption_info` to `EventTimelineItem`, which makes the code
look cleaner.

Signed-off-by: Kévin Commaille <[email protected]>
@zecakeh zecakeh force-pushed the fix-live-edit-json branch from a23393b to 9b351e4 Compare January 18, 2025 17:55
Copy link

codecov bot commented Jan 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.38%. Comparing base (47fc073) to head (9b351e4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4552      +/-   ##
==========================================
- Coverage   85.39%   85.38%   -0.01%     
==========================================
  Files         285      285              
  Lines       32213    32215       +2     
==========================================
- Hits        27509    27508       -1     
- Misses       4704     4707       +3     

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

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.

1 participant