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

feat(timeline): handle more timeline item content kinds in replied-to details #4649

Merged
merged 5 commits into from
Feb 12, 2025

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Feb 10, 2025

Right now, the replied-to details can only contain information about a room message, while we can have other timeline item contents for an item. In particular, the replied-to event could be still encrypted (UTD), and that shouldn't be considered an "unsupported kind", as in element-hq/element-x-ios#3774. Instead, consumers can display the replied-to event was a UTD, and perform manual retries in the background later on (after a backup key has been downloaded, for instance).

Remaining tasks:

  • Add tests that a UTD can appear in the replied-to details.
  • (and other kinds of contents: poll…
  • (…sticker, and so on)
  • [ ] Since the code getting a TimelineItemContent from a Ruma event is so similar to the code used when handling an event, I'm planning to attempt to merge the two.
    • will be a followup

@bnjbvr bnjbvr force-pushed the bnjbvr/reply-details branch from e95e74c to af30b47 Compare February 11, 2025 11:17
@bnjbvr bnjbvr marked this pull request as ready for review February 11, 2025 11:17
@bnjbvr bnjbvr requested a review from a team as a code owner February 11, 2025 11:17
@bnjbvr bnjbvr requested review from poljar and removed request for a team February 11, 2025 11:17
@bnjbvr
Copy link
Member Author

bnjbvr commented Feb 11, 2025

Note for reviewers: don't be afraid by the number of LOC, there are many repetitive tests in there.

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 64.86486% with 13 lines in your changes missing coverage. Please review.

Project coverage is 85.68%. Comparing base (69588d5) to head (335d884).
Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
...-sdk-ui/src/timeline/event_item/content/message.rs 64.86% 13 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4649   +/-   ##
=======================================
  Coverage   85.68%   85.68%           
=======================================
  Files         292      292           
  Lines       33570    33597   +27     
=======================================
+ Hits        28763    28788   +25     
- Misses       4807     4809    +2     

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

Comment on lines 403 to 412
let utd_info = as_variant!(
&timeline_event.kind,
TimelineEventKind::UnableToDecrypt { utd_info, .. } => utd_info
);

let utd_cause = if let Some(utd_info) = utd_info {
UtdCause::determine(
timeline_event.raw(),
room_data_provider.crypto_context_info().await,
&utd_info,
)
} else {
UtdCause::Unknown
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems simpler to use a single match for this, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea!

let content = match event.original_content() {
Some(content) => match content {
AnyMessageLikeEventContent::RoomMessage(c) => {
// Assume we're not interested in reactions in this context.
Copy link
Contributor

Choose a reason for hiding this comment

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

It might make sense to explain why we're not interested.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, edited with this comment:

// Assume we're not interested in reactions in this context: this is
// information for an embedded (replied-to) event, that will usually not
// include detailed information like reactions.

) => {
// Assume we're not interested in reactions in this context.
let reactions = ReactionsByKeyBySender::default();
// TODO could we provide the bundled edit here?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// TODO could we provide the bundled edit here?
// TODO: could we provide the bundled edit here?

@bnjbvr bnjbvr force-pushed the bnjbvr/reply-details branch from fdde8f1 to 335d884 Compare February 12, 2025 13:11
@bnjbvr bnjbvr enabled auto-merge (rebase) February 12, 2025 13:11
@bnjbvr bnjbvr merged commit 58099fd into main Feb 12, 2025
41 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/reply-details branch February 12, 2025 13:28
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.

3 participants