Properly handle Update all occurrences option

Closes https://github.com/SimpleMobileTools/Simple-Calendar/issues/981

The events were moved forward because the start and end timestamps from the repeating occurrence were saved instead of the original start and end times.

The call to `eventsHelper.addEventRepeatLimit()` was removed because I believe it was added there by mistake and the changes were overwritten anyways due to the next call to `eventsHelper.updateEvent()`. Another reason to remove it is to avoid triggering a CalDAV update which may interfere with the event update.
This commit is contained in:
Naveen 2023-05-29 04:41:09 +05:30
parent dea55ca94c
commit 2d33c1f8f0
No known key found for this signature in database
GPG Key ID: 0E155DAD31671DA3
2 changed files with 23 additions and 2 deletions

View File

@ -1386,7 +1386,19 @@ class EventActivity : SimpleActivity() {
}
EDIT_ALL_OCCURRENCES -> {
ensureBackgroundThread {
eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS)
// Shift the start and end times of the first (original) event based on the changes made
val originalEvent = eventsDB.getEventWithId(mEvent.id!!) ?: return@ensureBackgroundThread
val originalStartTS = originalEvent.startTS
val originalEndTS = originalEvent.endTS
val oldStartTS = mOriginalStartTS
val oldEndTS = mOriginalEndTS
mEvent.apply {
val startTSDelta = oldStartTS - startTS
val endTSDelta = oldEndTS - endTS
startTS = originalStartTS - startTSDelta
endTS = originalEndTS - endTSDelta
}
eventsHelper.updateEvent(mEvent, updateAtCalDAV = true, showToasts = true) {
finish()
}

View File

@ -502,7 +502,16 @@ class TaskActivity : SimpleActivity() {
}
EDIT_ALL_OCCURRENCES -> {
ensureBackgroundThread {
eventsHelper.addEventRepeatLimit(mTask.id!!, mTaskOccurrenceTS)
// Shift the start and end times of the first (original) event based on the changes made
val originalEvent = eventsDB.getTaskWithId(mTask.id!!) ?: return@ensureBackgroundThread
val originalStartTS = originalEvent.startTS
val oldStartTS = mOriginalStartTS
mTask.apply {
val startTSDelta = oldStartTS - startTS
startTS = originalStartTS - startTSDelta
endTS = startTS
}
eventsHelper.updateEvent(mTask, updateAtCalDAV = false, showToasts = true) {
finish()
}