From 6fe938632b8c32d105ec6696b7793ff97ab79ce3 Mon Sep 17 00:00:00 2001 From: Naveen Date: Wed, 14 Jun 2023 17:33:32 +0530 Subject: [PATCH 1/8] Properly handle `Update the selected occurrence only` Previously, if an event was modified using some other client then the exception event's parent id was ignored or overwritten with 0 at sync and that means the parent and child events were disconnected locally. Deleting the parent event did not delete the child event. If a recurrence was modified using Simple Calendar then it was disconnected from it's parent event both locally and on the server because `ORIGINAL_ID` and `ORIGINAL_INSTANCE_TIME` was not specified. On top of that, another exception event was created to make sure the parent event doesn't show up on the date of the disconnected child event. This change fixes these two issues. --- .../calendar/pro/activities/EventActivity.kt | 5 ++- .../calendar/pro/activities/TaskActivity.kt | 5 ++- .../calendar/pro/extensions/Context.kt | 2 +- .../calendar/pro/helpers/CalDAVHelper.kt | 36 +++++++++++++++---- .../calendar/pro/helpers/EventsHelper.kt | 18 +++++++++- 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index e3044aa8c..fac65a01e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -1155,7 +1155,7 @@ class EventActivity : SimpleActivity() { DeleteEventDialog(this, arrayListOf(mEvent.id!!), mEvent.repeatInterval > 0) { ensureBackgroundThread { when (it) { - DELETE_SELECTED_OCCURRENCE -> eventsHelper.addEventRepetitionException(mEvent.id!!, mEventOccurrenceTS, true) + DELETE_SELECTED_OCCURRENCE -> eventsHelper.deleteRepeatingEventOccurrence(mEvent.id!!, mEventOccurrenceTS, true) DELETE_FUTURE_OCCURRENCES -> eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS) DELETE_ALL_OCCURRENCES -> eventsHelper.deleteEvent(mEvent.id!!, true) } @@ -1361,7 +1361,6 @@ class EventActivity : SimpleActivity() { when (it) { EDIT_SELECTED_OCCURRENCE -> { ensureBackgroundThread { - eventsHelper.addEventRepetitionException(mEvent.id!!, mEventOccurrenceTS, true) mEvent.apply { parentId = id!!.toLong() id = null @@ -1370,7 +1369,7 @@ class EventActivity : SimpleActivity() { repeatLimit = 0 } - eventsHelper.insertEvent(mEvent, true, true) { + eventsHelper.insertEvent(mEvent, addToCalDAV = true, showToasts = true) { finish() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt index 8479b7bf6..ead2286d4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt @@ -474,7 +474,6 @@ class TaskActivity : SimpleActivity() { when (it) { EDIT_SELECTED_OCCURRENCE -> { ensureBackgroundThread { - eventsHelper.addEventRepetitionException(mTask.id!!, mTaskOccurrenceTS, addToCalDAV = false) mTask.apply { parentId = id!!.toLong() id = null @@ -533,9 +532,9 @@ class TaskActivity : SimpleActivity() { DeleteEventDialog(this, arrayListOf(mTask.id!!), mTask.repeatInterval > 0, isTask = true) { ensureBackgroundThread { when (it) { - DELETE_SELECTED_OCCURRENCE -> eventsHelper.addEventRepetitionException(mTask.id!!, mTaskOccurrenceTS, true) + DELETE_SELECTED_OCCURRENCE -> eventsHelper.deleteRepeatingEventOccurrence(mTask.id!!, mTaskOccurrenceTS, false) DELETE_FUTURE_OCCURRENCES -> eventsHelper.addEventRepeatLimit(mTask.id!!, mTaskOccurrenceTS) - DELETE_ALL_OCCURRENCES -> eventsHelper.deleteEvent(mTask.id!!, true) + DELETE_ALL_OCCURRENCES -> eventsHelper.deleteEvent(mTask.id!!, false) } runOnUiThread { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt index ad7a1f3e8..6820ad3c0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt @@ -696,7 +696,7 @@ fun Context.handleEventDeleting(eventIds: List, timestamps: List, ac when (action) { DELETE_SELECTED_OCCURRENCE -> { eventIds.forEachIndexed { index, value -> - eventsHelper.addEventRepetitionException(value, timestamps[index], true) + eventsHelper.deleteRepeatingEventOccurrence(value, timestamps[index], true) } } DELETE_FUTURE_OCCURRENCES -> { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index fadf3f93f..c05b322d7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -185,6 +185,7 @@ class CalDAVHelper(val context: Context) { Events.CALENDAR_TIME_ZONE, Events.DELETED, Events.AVAILABILITY, + Events.STATUS, Events.EVENT_COLOR ) @@ -214,6 +215,7 @@ class CalDAVHelper(val context: Context) { val reminders = getCalDAVEventReminders(id) val attendees = Gson().toJson(getCalDAVEventAttendees(id)) val availability = cursor.getIntValue(Events.AVAILABILITY) + val status = cursor.getIntValue(Events.STATUS) val color = cursor.getIntValueOrNull(Events.EVENT_COLOR) val displayColor = if (color != null) { getDisplayColorFromColor(color) @@ -255,14 +257,22 @@ class CalDAVHelper(val context: Context) { val parentImportId = "$source-$originalId" val parentEvent = context.eventsDB.getEventWithImportId(parentImportId) val originalDayCode = Formatter.getDayCodeFromTS(originalInstanceTime / 1000L) - if (parentEvent != null && !parentEvent.repetitionExceptions.contains(originalDayCode)) { - val storedEventId = context.eventsDB.getEventIdWithImportId(importId) - if (storedEventId != null) { - event.id = storedEventId + if (parentEvent != null) { + // add this event to the parent event's list of exceptions + if (!parentEvent.repetitionExceptions.contains(originalDayCode)) { + parentEvent.addRepetitionException(originalDayCode) + eventsHelper.insertEvent(parentEvent, addToCalDAV = false, showToasts = false) + } + + // store the event in the local db only if it is an occurrence that has been modified and not deleted + if (status != Events.STATUS_CANCELED) { + val storedEventId = context.eventsDB.getEventIdWithImportId(importId) + if (storedEventId != null) { + event.id = storedEventId + } + event.parentId = parentEvent.id!! + eventsHelper.insertEvent(event, addToCalDAV = false, showToasts = false) } - event.parentId = parentEvent.id!! - parentEvent.addRepetitionException(originalDayCode) - eventsHelper.insertEvent(parentEvent, addToCalDAV = false, showToasts = false) return@queryCursorInlined } @@ -432,6 +442,18 @@ class CalDAVHelper(val context: Context) { put(Events.ALL_DAY, 0) } + val parentEventId = event.parentId + if (parentEventId != 0L) { + val parentEvent = context.eventsDB.getEventWithId(parentEventId) ?: return@apply + put(Events.ORIGINAL_ID, parentEvent.getCalDAVEventId()) + put(Events.ORIGINAL_INSTANCE_TIME, event.startTS * 1000L) + if (parentEvent.getIsAllDay()) { + put(Events.ORIGINAL_ALL_DAY, 1) + } else { + put(Events.ORIGINAL_ALL_DAY, 0) + } + } + put(Events.DTSTART, event.startTS * 1000L) put(Events.EVENT_TIMEZONE, event.getTimeZoneString()) if (event.repeatInterval > 0) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt index fc9327c71..0b0f25d0b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt @@ -116,6 +116,14 @@ class EventsHelper(val context: Context) { return } + val parentEventId = event.parentId + if (parentEventId != 0L) { + val parentEvent = eventsDB.getEventOrTaskWithId(parentEventId) ?: return + val startDayCode = Formatter.getDayCodeFromTS(event.startTS) + parentEvent.addRepetitionException(startDayCode) + eventsDB.updateEventRepetitionExceptions(parentEvent.repetitionExceptions.toString(), parentEventId) + } + event.id = eventsDB.insertOrUpdate(event) context.updateWidgets() @@ -129,6 +137,14 @@ class EventsHelper(val context: Context) { } fun insertTask(task: Event, showToasts: Boolean, callback: () -> Unit) { + val parentEventId = task.parentId + if (parentEventId != 0L) { + val parentEvent = eventsDB.getEventOrTaskWithId(parentEventId) ?: return + val startDayCode = Formatter.getDayCodeFromTS(task.startTS) + parentEvent.addRepetitionException(startDayCode) + eventsDB.updateEventRepetitionExceptions(parentEvent.repetitionExceptions.toString(), parentEventId) + } + task.id = eventsDB.insertOrUpdate(task) context.updateWidgets() context.scheduleNextEventReminder(task, showToasts) @@ -232,7 +248,7 @@ class EventsHelper(val context: Context) { } } - fun addEventRepetitionException(parentEventId: Long, occurrenceTS: Long, addToCalDAV: Boolean) { + fun deleteRepeatingEventOccurrence(parentEventId: Long, occurrenceTS: Long, addToCalDAV: Boolean) { ensureBackgroundThread { val parentEvent = eventsDB.getEventOrTaskWithId(parentEventId) ?: return@ensureBackgroundThread var repetitionExceptions = parentEvent.repetitionExceptions From 13019e6835218e45f20e32ca37b380ed50b05efa Mon Sep 17 00:00:00 2001 From: Naveen Date: Thu, 15 Jun 2023 23:34:10 +0530 Subject: [PATCH 2/8] Check title before adding event to db --- .../com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index c05b322d7..494ce7781 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -265,7 +265,7 @@ class CalDAVHelper(val context: Context) { } // store the event in the local db only if it is an occurrence that has been modified and not deleted - if (status != Events.STATUS_CANCELED) { + if (status != Events.STATUS_CANCELED && title.isNotEmpty()) { val storedEventId = context.eventsDB.getEventIdWithImportId(importId) if (storedEventId != null) { event.id = storedEventId From dbfa1880b750d6e60c6c15f80a32bfc34f97b7fa Mon Sep 17 00:00:00 2001 From: Naveen Date: Thu, 15 Jun 2023 23:51:10 +0530 Subject: [PATCH 3/8] Code readability improvement --- .../calendar/pro/helpers/EventsHelper.kt | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt index 0b0f25d0b..38f593d1e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt @@ -116,14 +116,7 @@ class EventsHelper(val context: Context) { return } - val parentEventId = event.parentId - if (parentEventId != 0L) { - val parentEvent = eventsDB.getEventOrTaskWithId(parentEventId) ?: return - val startDayCode = Formatter.getDayCodeFromTS(event.startTS) - parentEvent.addRepetitionException(startDayCode) - eventsDB.updateEventRepetitionExceptions(parentEvent.repetitionExceptions.toString(), parentEventId) - } - + maybeUpdateParentExceptions(event) event.id = eventsDB.insertOrUpdate(event) context.updateWidgets() @@ -137,20 +130,24 @@ class EventsHelper(val context: Context) { } fun insertTask(task: Event, showToasts: Boolean, callback: () -> Unit) { - val parentEventId = task.parentId - if (parentEventId != 0L) { - val parentEvent = eventsDB.getEventOrTaskWithId(parentEventId) ?: return - val startDayCode = Formatter.getDayCodeFromTS(task.startTS) - parentEvent.addRepetitionException(startDayCode) - eventsDB.updateEventRepetitionExceptions(parentEvent.repetitionExceptions.toString(), parentEventId) - } - + maybeUpdateParentExceptions(task) task.id = eventsDB.insertOrUpdate(task) context.updateWidgets() context.scheduleNextEventReminder(task, showToasts) callback() } + private fun maybeUpdateParentExceptions(event: Event) { + // if the event is an exception from another event, update the parent event's exceptions list + val parentEventId = event.parentId + if (parentEventId != 0L) { + val parentEvent = eventsDB.getEventOrTaskWithId(parentEventId) ?: return + val startDayCode = Formatter.getDayCodeFromTS(event.startTS) + parentEvent.addRepetitionException(startDayCode) + eventsDB.updateEventRepetitionExceptions(parentEvent.repetitionExceptions.toString(), parentEventId) + } + } + fun insertEvents(events: ArrayList, addToCalDAV: Boolean) { try { for (event in events) { @@ -251,11 +248,9 @@ class EventsHelper(val context: Context) { fun deleteRepeatingEventOccurrence(parentEventId: Long, occurrenceTS: Long, addToCalDAV: Boolean) { ensureBackgroundThread { val parentEvent = eventsDB.getEventOrTaskWithId(parentEventId) ?: return@ensureBackgroundThread - var repetitionExceptions = parentEvent.repetitionExceptions - repetitionExceptions.add(Formatter.getDayCodeFromTS(occurrenceTS)) - repetitionExceptions = repetitionExceptions.distinct().toMutableList() as ArrayList - - eventsDB.updateEventRepetitionExceptions(repetitionExceptions.toString(), parentEventId) + val occurrenceDayCode = Formatter.getDayCodeFromTS(occurrenceTS) + parentEvent.addRepetitionException(occurrenceDayCode) + eventsDB.updateEventRepetitionExceptions(parentEvent.repetitionExceptions.toString(), parentEventId) context.scheduleNextEventReminder(parentEvent, false) if (addToCalDAV && config.caldavSync) { From 5ca7a67d6179255043814e35b2fa3e861361eb1c Mon Sep 17 00:00:00 2001 From: Naveen Date: Fri, 16 Jun 2023 00:07:18 +0530 Subject: [PATCH 4/8] Delete child tasks when parent task is deleted --- .../com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt index 17575838e..956e4257e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt @@ -103,7 +103,7 @@ interface EventsDao { @Query("SELECT id FROM events WHERE event_type IN (:eventTypeIds) AND type = $TYPE_EVENT") fun getEventIdsByEventType(eventTypeIds: List): List - @Query("SELECT id FROM events WHERE parent_id IN (:parentIds) AND type = $TYPE_EVENT") + @Query("SELECT id FROM events WHERE parent_id IN (:parentIds)") fun getEventIdsWithParentIds(parentIds: List): List @Query("SELECT id FROM events WHERE source = :source AND import_id != \"\" AND type = $TYPE_EVENT") From 3b0cec263f751181094bbba97ce0261d6fc05ff9 Mon Sep 17 00:00:00 2001 From: Naveen Date: Fri, 16 Jun 2023 03:02:01 +0530 Subject: [PATCH 5/8] Properly handle converting all-day recurring events to normal events --- .../calendar/pro/helpers/CalDAVHelper.kt | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index 494ce7781..37dd4eb42 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -435,6 +435,25 @@ class CalDAVHelper(val context: Context) { put(Events.RRULE, repeatRule) } + val parentEventId = event.parentId + if (parentEventId != 0L) { + val parentEvent = context.eventsDB.getEventWithId(parentEventId) ?: return@apply + val isParentAllDay = parentEvent.getIsAllDay() + // original instance time must be in UTC when the parent is an all-day event + val originalInstanceTS = if (isParentAllDay && !event.getIsAllDay()) { + Formatter.getShiftedUtcTS(event.startTS) + } else { + event.startTS + } + put(Events.ORIGINAL_ID, parentEvent.getCalDAVEventId()) + put(Events.ORIGINAL_INSTANCE_TIME, originalInstanceTS * 1000L) + if (isParentAllDay) { + put(Events.ORIGINAL_ALL_DAY, 1) + } else { + put(Events.ORIGINAL_ALL_DAY, 0) + } + } + if (event.getIsAllDay()) { event.toUtcAllDayEvent() put(Events.ALL_DAY, 1) @@ -442,18 +461,6 @@ class CalDAVHelper(val context: Context) { put(Events.ALL_DAY, 0) } - val parentEventId = event.parentId - if (parentEventId != 0L) { - val parentEvent = context.eventsDB.getEventWithId(parentEventId) ?: return@apply - put(Events.ORIGINAL_ID, parentEvent.getCalDAVEventId()) - put(Events.ORIGINAL_INSTANCE_TIME, event.startTS * 1000L) - if (parentEvent.getIsAllDay()) { - put(Events.ORIGINAL_ALL_DAY, 1) - } else { - put(Events.ORIGINAL_ALL_DAY, 0) - } - } - put(Events.DTSTART, event.startTS * 1000L) put(Events.EVENT_TIMEZONE, event.getTimeZoneString()) if (event.repeatInterval > 0) { From 6ede34c70e3a201a51ae8e4a01a41dc85ef0eb72 Mon Sep 17 00:00:00 2001 From: Naveen Date: Fri, 16 Jun 2023 04:09:26 +0530 Subject: [PATCH 6/8] Properly handle converting all-day recurring events to normal events --- .../calendar/pro/helpers/CalDAVHelper.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index 37dd4eb42..c3433ce39 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -435,6 +435,13 @@ class CalDAVHelper(val context: Context) { put(Events.RRULE, repeatRule) } + if (event.getIsAllDay()) { + event.toUtcAllDayEvent() + put(Events.ALL_DAY, 1) + } else { + put(Events.ALL_DAY, 0) + } + val parentEventId = event.parentId if (parentEventId != 0L) { val parentEvent = context.eventsDB.getEventWithId(parentEventId) ?: return@apply @@ -454,13 +461,6 @@ class CalDAVHelper(val context: Context) { } } - if (event.getIsAllDay()) { - event.toUtcAllDayEvent() - put(Events.ALL_DAY, 1) - } else { - put(Events.ALL_DAY, 0) - } - put(Events.DTSTART, event.startTS * 1000L) put(Events.EVENT_TIMEZONE, event.getTimeZoneString()) if (event.repeatInterval > 0) { From cd432b9ea6927f81081ef61f6bbd3e053d61db66 Mon Sep 17 00:00:00 2001 From: Naveen Date: Sun, 18 Jun 2023 19:59:39 +0530 Subject: [PATCH 7/8] Delete deleted CalDAV exception events on sync --- .../simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index c3433ce39..1482028b1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -272,6 +272,12 @@ class CalDAVHelper(val context: Context) { } event.parentId = parentEvent.id!! eventsHelper.insertEvent(event, addToCalDAV = false, showToasts = false) + } else { + // delete the deleted exception event from local db + val storedEventId = context.eventsDB.getEventIdWithImportId(importId) + if (storedEventId != null) { + eventsHelper.deleteEvent(storedEventId, false) + } } return@queryCursorInlined From 0ba02b9051bd630a64a1d3d1666ada36145922c0 Mon Sep 17 00:00:00 2001 From: Naveen Date: Sun, 18 Jun 2023 20:23:35 +0530 Subject: [PATCH 8/8] Delete deleted CalDAV exception events --- .../com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index 1482028b1..5fa7f4314 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -276,7 +276,7 @@ class CalDAVHelper(val context: Context) { // delete the deleted exception event from local db val storedEventId = context.eventsDB.getEventIdWithImportId(importId) if (storedEventId != null) { - eventsHelper.deleteEvent(storedEventId, false) + eventsHelper.deleteEvent(storedEventId, true) } }