Reaction summary view and sorting reactions by count and then timestamp (#942)

* Sort reactions by count and then timestamp

- Sort reactions within an aggregation by timestamp descending. This puts the most recent at the top, useful in cases like the reaction summary view or getting the most recent reaction.
- Sort aggregated reactions by count and then timestamp ascending, using the most recent reaction in the aggregation. This appends new aggregations on the end of the reaction layout.

* Add reaction summary view

* fix warnings

* Fix test unit tests and add sorting tests

- Fix broken build in test code
- Add a test for reaction sorting

* Remove default closure, move logic to presenter and add tests

* Update screenshots

* Fix imports

* Revert Screenshots I didn't update

* Fix imports remove screetshots

* Update screenshots

* Update screenshots

* Address comments.

* Update screenshots

* Remove unnecessary snapshotFlow

* Fix code quality checks

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
David Langley 2023-07-31 18:39:20 +01:00 committed by GitHub
parent ca3e284991
commit 0b95ef09b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 829 additions and 39 deletions

View file

@ -25,6 +25,7 @@ import io.element.android.libraries.matrix.api.timeline.item.event.EventReaction
import io.element.android.libraries.matrix.api.timeline.item.event.EventTimelineItem
import io.element.android.libraries.matrix.api.timeline.item.event.LocalEventSendState
import io.element.android.libraries.matrix.api.timeline.item.event.ProfileTimelineDetails
import io.element.android.libraries.matrix.api.timeline.item.event.ReactionSender
import org.matrix.rustcomponents.sdk.Reaction
import org.matrix.rustcomponents.sdk.EventItemOrigin as RustEventItemOrigin
import org.matrix.rustcomponents.sdk.EventSendState as RustEventSendState
@ -81,8 +82,12 @@ private fun List<Reaction>?.map(): List<EventReaction> {
return this?.map {
EventReaction(
key = it.key,
count = it.count.toLong(),
senderIds = it.senders.map { sender -> UserId(sender.senderId) }
senders = it.senders.map { sender ->
ReactionSender(
senderId = UserId(sender.senderId),
timestamp = sender.timestamp.toLong()
)
}
)
} ?: emptyList()
}