mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Editing: default to MessageContent.body
when no formattedBody
is present (#7592)
* Editing: default to `MessageContent.body` when no `formattedBody` is present * Update docs
This commit is contained in:
parent
54fcdcdb6d
commit
10775ab2f3
2 changed files with 4 additions and 1 deletions
1
changelog.d/7574.sdk
Normal file
1
changelog.d/7574.sdk
Normal file
|
@ -0,0 +1 @@
|
|||
If message content has no `formattedBody`, default to `body` when editing.
|
|
@ -180,11 +180,13 @@ fun TimelineEvent.isRootThread(): Boolean {
|
|||
|
||||
/**
|
||||
* Get the latest message body, after a possible edition, stripping the reply prefix if necessary.
|
||||
* @param formatted Indicates whether the formatted HTML body of the message should be retrieved of the plain text one.
|
||||
* @return If [formatted] is `true`, the HTML body of the message will be retrieved if available. Otherwise, the plain text/markdown version will be returned.
|
||||
*/
|
||||
fun TimelineEvent.getTextEditableContent(formatted: Boolean): String {
|
||||
val lastMessageContent = getLastMessageContent()
|
||||
val lastContentBody = if (formatted && lastMessageContent is MessageContentWithFormattedBody) {
|
||||
lastMessageContent.formattedBody
|
||||
lastMessageContent.formattedBody ?: lastMessageContent.body
|
||||
} else {
|
||||
lastMessageContent?.body
|
||||
} ?: return ""
|
||||
|
|
Loading…
Reference in a new issue