Code review: improve API.
This commit is contained in:
@@ -52,7 +52,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||
return when (val messageType = content.type ?: UnknownMessageType) {
|
||||
is EmoteMessageType -> TimelineItemEmoteContent(
|
||||
body = "* $senderDisplayName ${messageType.body}",
|
||||
htmlDocument = messageType.formatted?.toHtmlDocument(senderDisplayName),
|
||||
htmlDocument = messageType.formatted?.toHtmlDocument(prefix = "* senderDisplayName"),
|
||||
isEdited = content.isEdited,
|
||||
)
|
||||
is ImageMessageType -> {
|
||||
|
||||
@@ -21,10 +21,10 @@ import io.element.android.libraries.matrix.api.timeline.item.event.MessageFormat
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
|
||||
fun FormattedBody.toHtmlDocument(senderDisplayNamePrefix: String? = null): Document? {
|
||||
fun FormattedBody.toHtmlDocument(prefix: String? = null): Document? {
|
||||
return takeIf { it.format == MessageFormat.HTML }?.body?.let { formattedBody ->
|
||||
if (senderDisplayNamePrefix != null) {
|
||||
Jsoup.parse("* $senderDisplayNamePrefix $formattedBody")
|
||||
if (prefix != null) {
|
||||
Jsoup.parse("$prefix $formattedBody")
|
||||
} else {
|
||||
Jsoup.parse(formattedBody)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user