Fix a last bug when all editions has been deleted

This commit is contained in:
Benoit Marty 2021-03-02 11:30:30 +01:00
parent 95395945f2
commit 5d69a1ab91
1 changed files with 12 additions and 11 deletions

View File

@ -36,17 +36,18 @@ internal object EventAnnotationsSummaryMapper {
it.sourceLocalEcho.toList()
)
},
editSummary = annotationsSummary.editSummary?.let {
val latestEdition = it.editions.maxByOrNull { editionOfEvent -> editionOfEvent.timestamp }
EditAggregatedSummary(
ContentMapper.map(latestEdition?.content),
it.editions.filter { editionOfEvent -> !editionOfEvent.isLocalEcho }
.map { editionOfEvent -> editionOfEvent.eventId },
it.editions.filter { editionOfEvent -> editionOfEvent.isLocalEcho }
.map { editionOfEvent -> editionOfEvent.eventId },
latestEdition?.timestamp ?: 0L
)
},
editSummary = annotationsSummary.editSummary
?.let {
val latestEdition = it.editions.maxByOrNull { editionOfEvent -> editionOfEvent.timestamp } ?: return@let null
EditAggregatedSummary(
aggregatedContent = ContentMapper.map(latestEdition.content),
sourceEvents = it.editions.filter { editionOfEvent -> !editionOfEvent.isLocalEcho }
.map { editionOfEvent -> editionOfEvent.eventId },
localEchos = it.editions.filter { editionOfEvent -> editionOfEvent.isLocalEcho }
.map { editionOfEvent -> editionOfEvent.eventId },
lastEditTs = latestEdition.timestamp
)
},
referencesAggregatedSummary = annotationsSummary.referencesSummaryEntity?.let {
ReferencesAggregatedSummary(
it.eventId,