diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html/HtmlDocument.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html/HtmlDocument.kt index 82d73cc1a0..ecb81a4367 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html/HtmlDocument.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html/HtmlDocument.kt @@ -544,17 +544,27 @@ private fun AnnotatedString.Builder.appendLink(link: Element) { pop() } is PermalinkData.RoomEmailInviteLink -> { - appendInlineContent(CHIP_ID, link.ownText()) + safeAppendInlineContent(CHIP_ID, link.ownText()) } is PermalinkData.RoomLink -> { - appendInlineContent(CHIP_ID, link.ownText()) + safeAppendInlineContent(CHIP_ID, link.ownText()) } is PermalinkData.UserLink -> { - appendInlineContent(CHIP_ID, link.ownText()) + safeAppendInlineContent(CHIP_ID, link.ownText()) } } } +fun AnnotatedString.Builder.safeAppendInlineContent(chipId: String, ownText: String) { + if (ownText.isEmpty()) { + // alternateText cannot be empty and default parameter value is private, + // so just omit the second param here. + appendInlineContent(chipId) + } else { + appendInlineContent(chipId, ownText) + } +} + @Composable private fun HtmlText( text: AnnotatedString,