Fix formatting inconsistencies in latest event summaries (#6855)

* Fix message type prefixes formatting inconsistencies

* Use new string for the poll summary prefix instead of the A11y text. Also add tests check for the bold spans.

---------

Co-authored-by: Jorge Martín <jorgem@element.io>
This commit is contained in:
bxdxnn 2026-05-25 12:40:25 +03:00 committed by GitHub
parent ff263e611e
commit 23abc91510
4 changed files with 38 additions and 8 deletions

View file

@ -93,8 +93,8 @@ class DefaultRoomLatestEventFormatter(
message.prefixIfNeeded(senderDisambiguatedDisplayName, isDmRoom, isOutgoing)
}
is StickerContent -> {
val message = sp.getString(CommonStrings.common_sticker) + " (" + content.bestDescription + ")"
message.prefixIfNeeded(senderDisambiguatedDisplayName, isDmRoom, isOutgoing)
content.bestDescription.prefixWith(sp.getString(CommonStrings.common_sticker))
.prefixIfNeeded(senderDisambiguatedDisplayName, isDmRoom, isOutgoing)
}
is UnableToDecryptContent -> {
val message = sp.getString(CommonStrings.common_waiting_for_decryption_key)
@ -110,8 +110,8 @@ class DefaultRoomLatestEventFormatter(
stateContentFormatter.format(content, senderDisambiguatedDisplayName, isOutgoing, RenderingMode.RoomList)
}
is PollContent -> {
val message = sp.getString(CommonStrings.common_poll_summary, content.question)
message.prefixIfNeeded(senderDisambiguatedDisplayName, isDmRoom, isOutgoing)
content.question.prefixWith(sp.getString(CommonStrings.common_poll_summary_prefix))
.prefixIfNeeded(senderDisambiguatedDisplayName, isDmRoom, isOutgoing)
}
is FailedToParseMessageLikeContent, is FailedToParseStateContent, is UnknownContent -> {
val message = sp.getString(CommonStrings.common_unsupported_event)

View file

@ -20,6 +20,10 @@ internal fun CharSequence.prefixWith(prefix: String): AnnotatedString {
append(prefix)
}
append(": ")
append(this@prefixWith)
if (this@prefixWith is AnnotatedString) {
append(this@prefixWith)
} else {
append(this@prefixWith.toString())
}
}
}