Merge pull request #2093 from Naveen3Singh/recurring_event_fix_981

Properly handle `Update all occurrences` option
This commit is contained in:
Tibor Kaputa 2023-06-08 17:52:44 +02:00 committed by GitHub
commit b476e71ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -1306,6 +1306,9 @@ class EventActivity : SimpleActivity() {
// recreate the event if it was moved in a different CalDAV calendar
if (mEvent.id != null && oldSource != newSource && oldSource != SOURCE_IMPORTED_ICS) {
if (mRepeatInterval > 0 && wasRepeatable) {
applyOriginalStartEndTimes()
}
eventsHelper.deleteEvent(mEvent.id!!, true)
mEvent.id = null
}
@ -1386,7 +1389,7 @@ class EventActivity : SimpleActivity() {
}
EDIT_ALL_OCCURRENCES -> {
ensureBackgroundThread {
eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS)
applyOriginalStartEndTimes()
eventsHelper.updateEvent(mEvent, updateAtCalDAV = true, showToasts = true) {
finish()
}
@ -1396,6 +1399,22 @@ class EventActivity : SimpleActivity() {
}
}
private fun applyOriginalStartEndTimes() {
// Shift the start and end times of the first (original) event based on the changes made
val originalEvent = eventsDB.getEventWithId(mEvent.id!!) ?: return
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
}
}
private fun updateStartTexts() {
updateStartDateText()
updateStartTimeText()

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()
}