From 4a5fe3c0f918408abc25fce91d0652ddff6e067f Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 12 Jul 2022 14:49:20 +0200 Subject: [PATCH] Fix the criteria to start merging redacted events --- .../timeline/factory/MergedHeaderItemFactory.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt index 08d01c8614..2149857ec2 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt @@ -84,7 +84,7 @@ class MergedHeaderItemFactory @Inject constructor( buildRoomCreationMergedSummary(currentPosition, items, partialState, event, eventIdToHighlight, requestModelBuild, callback) isStartOfSameTypeEventsSummary(event, nextEvent, addDaySeparator) -> buildSameTypeEventsMergedSummary(currentPosition, items, partialState, event, eventIdToHighlight, requestModelBuild, callback) - isStartOfRedactedEventsSummary(event, nextEvent, addDaySeparator) -> + isStartOfRedactedEventsSummary(event, items, currentPosition, addDaySeparator) -> buildRedactedEventsMergedSummary(currentPosition, items, partialState, event, eventIdToHighlight, requestModelBuild, callback) else -> null } @@ -120,16 +120,21 @@ class MergedHeaderItemFactory @Inject constructor( /** * @param event the main timeline event - * @param nextEvent is an older event than event + * @param items all known items, sorted from newer event to oldest event + * @param currentPosition the current position * @param addDaySeparator true to add a day separator */ private fun isStartOfRedactedEventsSummary( event: TimelineEvent, - nextEvent: TimelineEvent?, + items: List, + currentPosition: Int, addDaySeparator: Boolean, ): Boolean { + val nextNonRedactionEvent = items + .subList(fromIndex = currentPosition + 1, toIndex = items.size) + .find { it.root.getClearType() != EventType.REDACTION } return event.root.isRedacted() && - ((nextEvent?.root?.getClearType() != EventType.REDACTION && !nextEvent?.root?.isRedacted().orFalse()) || addDaySeparator) + (!nextNonRedactionEvent?.root?.isRedacted().orFalse() || addDaySeparator) } private fun buildSameTypeEventsMergedSummary(