From 320aae1430d7e23d514d09263a990434bd23d4a6 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 20 Dec 2023 20:46:19 +0100 Subject: [PATCH] Also fix pills with rich text editor --- .../internal/session/room/relation/EventEditor.kt | 1 + .../session/room/send/LocalEchoEventFactory.kt | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/EventEditor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/EventEditor.kt index f0ea4c4d07..67433033d2 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/EventEditor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/EventEditor.kt @@ -131,6 +131,7 @@ internal class EventEditor @Inject constructor( replyToEdit, originalTimelineEvent, newBodyText, + newBodyFormattedText, true, MessageType.MSGTYPE_TEXT, compatibilityBodyText diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt index 1e87a5d005..78328ea4cc 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt @@ -312,7 +312,8 @@ internal class LocalEchoEventFactory @Inject constructor( roomId: String, eventReplaced: TimelineEvent, originalEvent: TimelineEvent, - newBodyText: CharSequence, + replyText: CharSequence, + replyTextFormatted: String?, autoMarkdown: Boolean, msgType: String, compatibilityText: String, @@ -321,22 +322,22 @@ internal class LocalEchoEventFactory @Inject constructor( val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "", false) val userLink = originalEvent.root.senderId?.let { permalinkFactory.createPermalink(it, false) } ?: "" - val body = bodyForReply(timelineEvent = originalEvent) + val bodyOfRepliedEvent = bodyForReply(timelineEvent = originalEvent) // As we always supply formatted body for replies we should force the MarkdownParser to produce html. - val newBodyFormatted = markdownParser.parse(newBodyText, force = true, advanced = autoMarkdown).takeFormatted() + val newBodyFormatted = replyTextFormatted ?: markdownParser.parse(replyText, force = true, advanced = autoMarkdown).takeFormatted() // Body of the original message may not have formatted version, so may also have to convert to html. - val bodyFormatted = body.formattedText ?: markdownParser.parse(body.text, force = true, advanced = autoMarkdown).takeFormatted() + val formattedBodyOfRepliedEvent = bodyOfRepliedEvent.formattedText ?: markdownParser.parse(bodyOfRepliedEvent.text, force = true, advanced = autoMarkdown).takeFormatted() val replyFormatted = buildFormattedReply( permalink, userLink, originalEvent.senderInfo.disambiguatedDisplayName, - bodyFormatted, + formattedBodyOfRepliedEvent, newBodyFormatted ) // // > <@alice:example.org> This is the original body // - val replyFallback = buildReplyFallback(body, originalEvent.root.senderId ?: "", newBodyText.toString()) + val replyFallback = buildReplyFallback(bodyOfRepliedEvent, originalEvent.root.senderId ?: "", replyText.toString()) return createMessageEvent( roomId,