diff --git a/changelog.d/7574.sdk b/changelog.d/7574.sdk new file mode 100644 index 0000000000..3757334138 --- /dev/null +++ b/changelog.d/7574.sdk @@ -0,0 +1 @@ +If message content has no `formattedBody`, default to `body` when editing. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt index 223acd1b9c..6f4049de36 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt @@ -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 ""