From 37429c277b8b7496ba2e90c3c2b50426e389a9c9 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 26 May 2023 11:57:18 +0100 Subject: [PATCH] Show correct details when a poll is ended. Previously, the "end poll" timeline item always showed the title and options from the start event, regardless of whether any edits had been made. Now we show the latest edit, if available, falling back to the original otherwise. --- changelog.d/8471.bugfix | 1 + .../home/room/detail/timeline/factory/MessageItemFactory.kt | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog.d/8471.bugfix diff --git a/changelog.d/8471.bugfix b/changelog.d/8471.bugfix new file mode 100644 index 0000000000..ff0b0f5493 --- /dev/null +++ b/changelog.d/8471.bugfix @@ -0,0 +1 @@ +The correct title and options are now displayed When a poll that was edited is ended. 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 09b91cc4f1..85e4db4091 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 @@ -286,7 +286,10 @@ class MessageItemFactory @Inject constructor( } else { null } - val pollContent = pollStartEvent?.root?.getClearContent()?.toModel() + + val editedContent = pollStartEvent?.annotations?.editSummary?.latestEdit?.getClearContent()?.toModel()?.newContent + val latestContent = editedContent ?: pollStartEvent?.root?.getClearContent() + val pollContent = latestContent?.toModel() return if (pollContent == null) { val title = stringProvider.getString(R.string.message_reply_to_ended_poll_preview).toEpoxyCharSequence()