Code review: improve API.
This commit is contained in:
parent
0610306f9a
commit
3559b2ed4b
2 changed files with 4 additions and 4 deletions
|
|
@ -52,7 +52,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
return when (val messageType = content.type ?: UnknownMessageType) {
|
return when (val messageType = content.type ?: UnknownMessageType) {
|
||||||
is EmoteMessageType -> TimelineItemEmoteContent(
|
is EmoteMessageType -> TimelineItemEmoteContent(
|
||||||
body = "* $senderDisplayName ${messageType.body}",
|
body = "* $senderDisplayName ${messageType.body}",
|
||||||
htmlDocument = messageType.formatted?.toHtmlDocument(senderDisplayName),
|
htmlDocument = messageType.formatted?.toHtmlDocument(prefix = "* senderDisplayName"),
|
||||||
isEdited = content.isEdited,
|
isEdited = content.isEdited,
|
||||||
)
|
)
|
||||||
is ImageMessageType -> {
|
is ImageMessageType -> {
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ import io.element.android.libraries.matrix.api.timeline.item.event.MessageFormat
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import org.jsoup.nodes.Document
|
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 ->
|
return takeIf { it.format == MessageFormat.HTML }?.body?.let { formattedBody ->
|
||||||
if (senderDisplayNamePrefix != null) {
|
if (prefix != null) {
|
||||||
Jsoup.parse("* $senderDisplayNamePrefix $formattedBody")
|
Jsoup.parse("$prefix $formattedBody")
|
||||||
} else {
|
} else {
|
||||||
Jsoup.parse(formattedBody)
|
Jsoup.parse(formattedBody)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue