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.
This commit is contained in:
Chris Smith 2023-05-26 11:57:18 +01:00
parent 8f69e411d7
commit 37429c277b
2 changed files with 5 additions and 1 deletions

1
changelog.d/8471.bugfix Normal file
View File

@ -0,0 +1 @@
The correct title and options are now displayed When a poll that was edited is ended.

View File

@ -286,7 +286,10 @@ class MessageItemFactory @Inject constructor(
} else { } else {
null null
} }
val pollContent = pollStartEvent?.root?.getClearContent()?.toModel<MessagePollContent>()
val editedContent = pollStartEvent?.annotations?.editSummary?.latestEdit?.getClearContent()?.toModel<MessagePollContent>()?.newContent
val latestContent = editedContent ?: pollStartEvent?.root?.getClearContent()
val pollContent = latestContent?.toModel<MessagePollContent>()
return if (pollContent == null) { return if (pollContent == null) {
val title = stringProvider.getString(R.string.message_reply_to_ended_poll_preview).toEpoxyCharSequence() val title = stringProvider.getString(R.string.message_reply_to_ended_poll_preview).toEpoxyCharSequence()