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

Clarify model for Event with attachment #3574

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Oct 1, 2024

Content

Clarify model for Event with attachment. They must have a filename: String and they may have a body :String? (caption).

If filename is missing from the SDK model, the body is used instead and in this case the body is not mapped to our model.

Motivation and context

Cleanup following change in #3567
The changes here should reduce the risk of errors.

Screenshots / GIFs

Tests

  • Should not have any impact.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

Copy link
Contributor

github-actions bot commented Oct 1, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/h9Nm3r

@bmarty bmarty force-pushed the feature/bma/improveMediaModel branch from 5ea9bde to 8668f72 Compare October 1, 2024 12:41
@bmarty bmarty added the PR-Misc For other changes label Oct 1, 2024
@bmarty bmarty changed the title Clarify model for Event with attachment. They must have a `filename: … Clarify model for Event with attachment Oct 1, 2024
@bmarty bmarty force-pushed the feature/bma/improveMediaModel branch from 8668f72 to 2de51bc Compare October 1, 2024 13:25
@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 2, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 2, 2024
@bmarty bmarty marked this pull request as ready for review October 2, 2024 12:12
@bmarty bmarty requested a review from a team as a code owner October 2, 2024 12:12
@bmarty bmarty requested review from ganfra and removed request for a team October 2, 2024 12:12
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

Attention: Patch coverage is 85.22167% with 30 lines in your changes missing coverage. Please review.

Project coverage is 82.63%. Comparing base (5a4e5d0) to head (6ea11fa).
Report is 26 commits behind head on develop.

Files with missing lines Patch % Lines
...ctories/event/TimelineItemContentMessageFactory.kt 64.00% 4 Missing and 5 partials ⚠️
...mediaviewer/impl/local/AndroidLocalMediaFactory.kt 57.14% 6 Missing ⚠️
...timeline/components/event/TimelineItemVideoView.kt 50.00% 3 Missing and 1 partial ⚠️
...timeline/components/event/TimelineItemImageView.kt 25.00% 3 Missing ⚠️
...eatures/messages/impl/actionlist/ActionListView.kt 80.00% 1 Missing ⚠️
...meline/components/event/TimelineItemStickerView.kt 50.00% 0 Missing and 1 partial ⚠️
...atter/impl/DefaultPinnedMessagesBannerFormatter.kt 87.50% 0 Missing and 1 partial ⚠️
...ies/matrix/api/timeline/item/event/EventContent.kt 66.66% 0 Missing and 1 partial ⚠️
...ries/matrix/api/timeline/item/event/MessageType.kt 94.73% 0 Missing and 1 partial ⚠️
.../libraries/matrix/test/timeline/TimelineFixture.kt 85.71% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3574      +/-   ##
===========================================
- Coverage    82.65%   82.63%   -0.03%     
===========================================
  Files         1735     1735              
  Lines        41191    41262      +71     
  Branches      4999     5005       +6     
===========================================
+ Hits         34047    34096      +49     
- Misses        5381     5394      +13     
- Partials      1763     1772       +9     

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

Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

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

I think this is the opposite, from reading the spec?

body | string | Required: If filename is not set or the value of both properties are identical, this is the filename of the original upload. Otherwise, this is a caption for the image.Changed in v1.10: This property can act as a caption for the image.

filename | string | The original filename of the uploaded file.Added in v1.10

The filename is mandatory but the body is not ^

@bmarty
Copy link
Member Author

bmarty commented Oct 2, 2024

We are just mapping what the SDK is providing to the application here. There is maybe a problem in the SDK then?

@ganfra
Copy link
Member

ganfra commented Oct 2, 2024

We are just mapping what the SDK is providing to the application here. There is maybe a problem in the SDK then?

Mmm AFAICT, the SDK returns a non-nullable body and a nullable filename?

@bmarty
Copy link
Member Author

bmarty commented Oct 2, 2024

Yes, I have read it too fast, my bad

The mapping I have done in the EventContentMapper is still correct to me, and the application needs a non-nullable filename.

So we always have a filename, which may be from the body and we have an optional body which is actually either the filename, or the caption. Do you see a problem with this approach?

@ganfra
Copy link
Member

ganfra commented Oct 3, 2024

I think we should keep the mapping as they come from sdk, otherwise it brings confusion.
I'd instead offer some methods to get the correct value (or computed val),
like computedFilename() and computedCaption()

@bmarty
Copy link
Member Author

bmarty commented Oct 3, 2024

OK, let's wait for the SDK to change, I think this is discussed in #2570.

@bmarty bmarty marked this pull request as draft October 3, 2024 09:49
@pixlwave
Copy link
Member

pixlwave commented Oct 7, 2024

Heads up that this is now available in the SDK: matrix-org/matrix-rust-sdk#4081

mediaTimelineItem.filename will always be the filename and mediaTimelineItem.caption/formattedCaption will only exist when there's a caption to be rendered.

@bmarty bmarty force-pushed the feature/bma/improveMediaModel branch from fd750f0 to 6ea11fa Compare October 8, 2024 15:17
Copy link

sonarcloud bot commented Oct 8, 2024

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 8, 2024
@bmarty bmarty marked this pull request as ready for review October 8, 2024 16:02
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 8, 2024
@bmarty
Copy link
Member Author

bmarty commented Oct 8, 2024

@ganfra PR updated with what is provided in matrix-org/matrix-rust-sdk#4081

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Misc For other changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants