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 linkify #2040

Merged
merged 12 commits into from
Dec 18, 2023
Merged

fix linkify #2040

merged 12 commits into from
Dec 18, 2023

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Dec 15, 2023

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Ensure message with body and without formatted body got working links.
Also ensure email addresses are linkified.

Motivation and context

Closes #2038

Screenshots / GIFs

Tests

  • Send a message with just a raw link and nothing else
  • Observe that with this change the link in the message is rendered as a link and is clickable

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@bmarty bmarty requested a review from a team as a code owner December 15, 2023 14:08
@bmarty bmarty requested review from ganfra and removed request for a team December 15, 2023 14:08
Copy link
Contributor

github-actions bot commented Dec 15, 2023

📱 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/fwSKHL

TimelineItemEmoteContent(
body = emoteBody,
htmlDocument = messageType.formatted?.toHtmlDocument(prefix = "* $senderDisplayName"),
formattedBody = parseHtml(messageType.formatted, prefix = "* $senderDisplayName") ?: emoteBody.withLinks(),
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly, we always have a formattedBody now with those fixes. Could we simplify a bit the TimelineItemTextBasedContent interface then?
It's a bit hard to know what to use currently, and we probably don't need all the fields.

sealed interface TimelineItemTextBasedContent : TimelineItemEventContent {
    val body: String
    val htmlDocument: Document?
    val formattedBody: CharSequence?
    val plainText: String
    val isEdited: Boolean
    val htmlBody: String?
        get() = htmlDocument?.body()?.html()
}

Copy link
Member Author

Choose a reason for hiding this comment

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

we always have a formattedBody

No, withLinks() returns null if no links are added.

Copy link
Member

Choose a reason for hiding this comment

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

Can we still try to simplify the api?
If we could get a plainText/formattedText/body/htmlBody and remove the htmlDocument instance?
I'd say, The formattedText shouldn't be nullable and should always be displayed in timeline.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I would prefer to do that in a separate rework PR. OK for you?

Copy link
Member

Choose a reason for hiding this comment

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

as u want

@frebib
Copy link
Contributor

frebib commented Dec 15, 2023

Would we ever consider also detecting and formatting raw user/room mentions in this way too, for clients that only send unformatted bodies?

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Dec 15, 2023
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Dec 15, 2023
consumeItemsUntilPredicate { it.showSyncSpinner }
roomListService.postState(RoomListService.State.Running)
roomListService.postSyncIndicator(RoomListService.SyncIndicator.Hide)
Copy link
Member Author

@bmarty bmarty Dec 15, 2023

Choose a reason for hiding this comment

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

consumeItemsUntilPredicate now expects the predicate to be true at some point, so I had to fix this outdated test.

Copy link

sonarcloud bot commented Dec 17, 2023

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

codecov bot commented Dec 17, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (4c987c5) 67.64% compared to head (0129fdd) 67.61%.

Files Patch % Lines
...ctories/event/TimelineItemContentMessageFactory.kt 92.85% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2040      +/-   ##
===========================================
- Coverage    67.64%   67.61%   -0.03%     
===========================================
  Files         1349     1349              
  Lines        33813    33819       +6     
  Branches      7263     7268       +5     
===========================================
- Hits         22872    22867       -5     
- Misses        7493     7503      +10     
- Partials      3448     3449       +1     

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

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Dec 17, 2023
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Dec 17, 2023
@bmarty bmarty requested a review from ganfra December 17, 2023 17:21
@bmarty bmarty merged commit cde8e0d into develop Dec 18, 2023
17 of 18 checks passed
@bmarty bmarty deleted the feature/bma/fixLinkify branch December 18, 2023 13:51
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.

Messages are not linkified anymore
3 participants