From ff67571dadcf6972d444f36d4ae4994b6d04186a Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Wed, 2 Aug 2023 20:04:06 +0200 Subject: [PATCH] Fix html messages not rendering at all on markwon exception If render(): renderAndProcess(markwon.parse(text), _) fails, the input text *string* is returned instead of a Spannable, so we shouldn't cast without checking here. Fixes https://github.com/SchildiChat/SchildiChat-android/issues/201 Change-Id: I1824328e0b733de699a33376833b2fbc86b0e44f --- .../home/room/detail/timeline/factory/MessageItemFactory.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index e2099df1a4..1292e2fca0 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -679,8 +679,9 @@ class MessageItemFactory @Inject constructor( ?: matrixFormattedBody */ val compressed = htmlCompressor.compress(matrixFormattedBody) - val renderedFormattedBody = htmlRenderer.get().render(compressed, pillsPostProcessor) as Spanned - val pseudoEmojiBody = htmlRenderer.get().render(customToPseudoEmoji(compressed), pillsPostProcessor) as Spanned + val renderedFormattedBody = htmlRenderer.get().render(compressed, pillsPostProcessor) as? Spanned ?: compressed + val pseudoEmojiCompressed = customToPseudoEmoji(compressed) + val pseudoEmojiBody = htmlRenderer.get().render(pseudoEmojiCompressed, pillsPostProcessor) as? Spanned ?: pseudoEmojiCompressed return buildMessageTextItem( renderedFormattedBody, true,