fixing message starts being cutoff due to expecting a reply tag to exist

This commit is contained in:
Adam Brown 2022-05-08 19:02:54 +01:00
parent e85d7a5ede
commit 299c6af27a
2 changed files with 11 additions and 6 deletions

View File

@ -162,11 +162,6 @@ internal class TimelineEventMapper(
}
private fun String.stripTags() = this.substring(this.indexOf("</mx-reply>") + "</mx-reply>".length)
.trim()
.replace("<em>", "")
.replace("</em>", "")
private fun ApiTimelineEvent.TimelineMessage.isEdit() = this.content.relation?.relationType == "m.replace" && this.content.relation?.eventId != null
private fun ApiTimelineEvent.TimelineMessage.isReply() = this.content.relation?.inReplyTo != null
private fun ApiTimelineEvent.TimelineMessage.asTextContent() = this.content as ApiTimelineEvent.TimelineMessage.Content.Text

View File

@ -53,9 +53,19 @@ internal class RoomEventFactory(
}
}
private fun String.stripTags() = this.substring(this.indexOf("</mx-reply>") + "</mx-reply>".length)
private fun String.indexOfOrNull(string: String) = this.indexOf(string).takeIf { it != -1 }
fun String.stripTags() = this
.run {
this.indexOfOrNull("</mx-reply>")?.let {
this.substring(it + "</mx-reply>".length)
} ?: this
}
.trim()
.replace("<em>", "")
.replace("</em>", "")
.replace("&quot;", "\"")
.replace("&#39;", "'")
private fun ApiTimelineEvent.TimelineMessage.asTextContent() = this.content as ApiTimelineEvent.TimelineMessage.Content.Text