From 025dcc8d884e83fa95fcdddf9ed1ce21b28dc121 Mon Sep 17 00:00:00 2001 From: Claire G Date: Mon, 14 Mar 2022 10:28:42 +0100 Subject: [PATCH] Fix bug: readReceipt in wrong order --- changelog.d/5514.bugfix | 1 + .../timeline/factory/ReadReceiptsItemFactory.kt | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 changelog.d/5514.bugfix diff --git a/changelog.d/5514.bugfix b/changelog.d/5514.bugfix new file mode 100644 index 0000000000..0dfbca6e9a --- /dev/null +++ b/changelog.d/5514.bugfix @@ -0,0 +1 @@ +Read receipt in wrong order \ No newline at end of file diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/ReadReceiptsItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/ReadReceiptsItemFactory.kt index e66dd4b043..502f17e78b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/ReadReceiptsItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/ReadReceiptsItemFactory.kt @@ -37,17 +37,22 @@ class ReadReceiptsItemFactory @Inject constructor(private val avatarRenderer: Av val readReceiptsData = readReceipts .map { ReadReceiptData(it.roomMember.userId, it.roomMember.avatarUrl, it.roomMember.displayName, it.originServerTs) - } - .toList() - + }.toList() + val readReceiptsDataSorted = sortItem(readReceiptsData) return ReadReceiptsItem_() .id("read_receipts_$eventId") .eventId(eventId) - .readReceipts(readReceiptsData) + .readReceipts(readReceiptsDataSorted) .avatarRenderer(avatarRenderer) .shouldHideReadReceipts(isFromThreadTimeLine) .clickListener { - callback?.onReadReceiptsClicked(readReceiptsData) + callback?.onReadReceiptsClicked(readReceiptsDataSorted) } } + + fun sortItem(readReceipt: List): List { + return readReceipt.sortedByDescending { + it.timestamp + } + } }