Code review: improve API.
This commit is contained in:
parent
73f8aa0887
commit
35b7b661f2
2 changed files with 4 additions and 4 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue