-
Notifications
You must be signed in to change notification settings - Fork 160
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 pillification not working for non formatted message bodies #3201
Fix pillification not working for non formatted message bodies #3201
Conversation
Pure Markdown bodies weren't being 'pillified' so their mentions were turned into UI elements in the timeline. A new `pillifiedBody` property was added to `TimelineItemTextBasedContent` to fix this.
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3201 +/- ##
========================================
Coverage 76.15% 76.15%
========================================
Files 1645 1645
Lines 38738 38747 +9
Branches 7496 7496
========================================
+ Hits 29501 29509 +8
Misses 5343 5343
- Partials 3894 3895 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the pillification is working as expected. But there are still difference when sending @room
from Element Web and from EXA (tested in a DM):
Also on EXA I do not have completion for @room
, I have it on Web. This may be fixed later, not related to this PR.
EDIT: apparently this is working as expected: code
remember(content.pillifiedBody, mentionSpanTheme, lastCacheUpdate) { | ||
updateMentionSpans(content.pillifiedBody, userProfileCache) | ||
mentionSpanTheme.updateMentionStyles(content.pillifiedBody) | ||
content.pillifiedBody |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is all this block equivalent to this simpler form?
val formattedBody = content.formattedBody ?: content.pillifiedBody
val textWithMentions = remember(formattedBody, mentionSpanTheme, lastCacheUpdate) {
updateMentionSpans(formattedBody, userProfileCache)
mentionSpanTheme.updateMentionStyles(formattedBody)
formattedBody
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, nice catch!
val isEdited: Boolean | ||
|
||
/** The raw HTML body of the event. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kudos for adding some documentation 👍
package io.element.android.features.messages.impl.utils | ||
|
||
class FakeTextPillificationHelper( | ||
private val pillifyLambda: (CharSequence) -> CharSequence = { it } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to have a default lambda content with lambdaError()
so that we ensure that it's not called when it's not expected, which is actually doing more test. Note that in this particular case, this is maybe OK to keep the current default implementation. I let you choose what's best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component is sometimes used as a dependency deep in the hierarchy so I think it's better to not have to customise it for testing other components that may depend on it for functionality but don't check its output.
Quality Gate passedIssues Measures |
Content
Pure Markdown bodies weren't being 'pillified' so their mentions were turned into UI elements in the timeline.
A new
pillifiedBody
property was added toTimelineItemTextBasedContent
to fix this.Motivation and context
#2966
Screenshots / GIFs
There shouldn't be any changes 🤞 .
Tests
@room
mention.@room
pill.Tested devices
Checklist