Remove extra space in <mx-reply>

This commit is contained in:
Benoit Marty 2019-07-10 10:07:45 +02:00
parent e6c74dc1fe
commit 228ee52563

View file

@ -260,21 +260,19 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
// </mx-reply>
// This is where the reply goes.
val body = bodyForReply(eventReplied.getClearContent().toModel<MessageContent>())
val replyFallbackTemplateFormatted = """<mx-reply>
<blockquote>
<a href="%s">${stringProvider.getString(R.string.message_reply_to_prefix)}</a>
<a href="%s">%s</a>
<br />
%s
</blockquote>
</mx-reply>
%s""".trimIndent().format(permalink, userLink, userId, body.second ?: body.first, replyText)
val replyFallbackTemplateFormatted = REPLY_PATTERN.format(
permalink,
stringProvider.getString(R.string.message_reply_to_prefix),
userLink,
userId,
body.second ?: body.first,
replyText
)
//
// > <@alice:example.org> This is the original body
//
// This is where the reply goes
val lines = body.first.split("\n")
val plainTextBody = StringBuffer("><${userId}>")
val plainTextBody = StringBuffer("><$userId>")
lines.firstOrNull()?.also { plainTextBody.append(" $it") }
lines.forEachIndexed { index, s ->
if (index > 0) {
@ -365,6 +363,9 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
companion object {
const val LOCAL_ID_PREFIX = "local."
// No whitespace
const val REPLY_PATTERN = """<mx-reply><blockquote><a href="%s">%s</a><a href="%s">%s</a><br />%s</blockquote></mx-reply>%s"""
fun isLocalEchoId(eventId: String): Boolean = eventId.startsWith(LOCAL_ID_PREFIX)
}
}