From 9258fd4ad22c6282eedc2ea58ea36c55dbd39483 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 3 Dec 2018 15:44:33 +0100 Subject: [PATCH] fix some event duplication in sequences --- .../com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt index 76ce0086b..41d27bcd3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt @@ -141,7 +141,8 @@ class IcsImporter(val activity: SimpleActivity) { continue } - val eventToUpdate = existingEvents.firstOrNull { curImportId.isNotEmpty() && curImportId == it.importId } + // repeating event exceptions can have the same import id as their parents, so pick the latest event to update + val eventToUpdate = existingEvents.filter { curImportId.isNotEmpty() && curImportId == it.importId }.sortedByDescending { it.lastUpdated }.firstOrNull() if (eventToUpdate != null && eventToUpdate.lastUpdated >= curLastModified) { continue }