forked from GitHub-Mirror/riotX-android
Code clarity
This commit is contained in:
parent
228ee52563
commit
0a54801fcc
@ -260,7 +260,7 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
|
|||||||
// </mx-reply>
|
// </mx-reply>
|
||||||
// This is where the reply goes.
|
// This is where the reply goes.
|
||||||
val body = bodyForReply(eventReplied.getClearContent().toModel<MessageContent>())
|
val body = bodyForReply(eventReplied.getClearContent().toModel<MessageContent>())
|
||||||
val replyFallbackTemplateFormatted = REPLY_PATTERN.format(
|
val replyFormatted = REPLY_PATTERN.format(
|
||||||
permalink,
|
permalink,
|
||||||
stringProvider.getString(R.string.message_reply_to_prefix),
|
stringProvider.getString(R.string.message_reply_to_prefix),
|
||||||
userLink,
|
userLink,
|
||||||
@ -272,21 +272,22 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
|
|||||||
// > <@alice:example.org> This is the original body
|
// > <@alice:example.org> This is the original body
|
||||||
//
|
//
|
||||||
val lines = body.first.split("\n")
|
val lines = body.first.split("\n")
|
||||||
val plainTextBody = StringBuffer("><$userId>")
|
val replyFallback = StringBuffer("><$userId>")
|
||||||
lines.firstOrNull()?.also { plainTextBody.append(" $it") }
|
|
||||||
lines.forEachIndexed { index, s ->
|
lines.forEachIndexed { index, s ->
|
||||||
if (index > 0) {
|
if (index == 0) {
|
||||||
plainTextBody.append("\n>$s")
|
replyFallback.append(" $s")
|
||||||
|
} else {
|
||||||
|
replyFallback.append("\n>$s")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plainTextBody.append("\n\n").append(replyText)
|
replyFallback.append("\n\n").append(replyText)
|
||||||
|
|
||||||
val eventId = eventReplied.eventId ?: return null
|
val eventId = eventReplied.eventId ?: return null
|
||||||
val content = MessageTextContent(
|
val content = MessageTextContent(
|
||||||
type = MessageType.MSGTYPE_TEXT,
|
type = MessageType.MSGTYPE_TEXT,
|
||||||
format = MessageType.FORMAT_MATRIX_HTML,
|
format = MessageType.FORMAT_MATRIX_HTML,
|
||||||
body = plainTextBody.toString(),
|
body = replyFallback.toString(),
|
||||||
formattedBody = replyFallbackTemplateFormatted,
|
formattedBody = replyFormatted,
|
||||||
relatesTo = RelationDefaultContent(null, null, ReplyToContent(eventId))
|
relatesTo = RelationDefaultContent(null, null, ReplyToContent(eventId))
|
||||||
)
|
)
|
||||||
return createEvent(roomId, content)
|
return createEvent(roomId, content)
|
||||||
@ -315,9 +316,7 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
|
|||||||
MessageType.MSGTYPE_IMAGE -> return stringProvider.getString(R.string.reply_to_an_image) to null
|
MessageType.MSGTYPE_IMAGE -> return stringProvider.getString(R.string.reply_to_an_image) to null
|
||||||
MessageType.MSGTYPE_VIDEO -> return stringProvider.getString(R.string.reply_to_a_video) to null
|
MessageType.MSGTYPE_VIDEO -> return stringProvider.getString(R.string.reply_to_a_video) to null
|
||||||
else -> return (content?.body ?: "") to null
|
else -> return (content?.body ?: "") to null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user