End repetition on the original date
The bug: - Create a recurring event with a specific number of occurrences like 10 that starts on Jan 1 - Edit some occurrence e.g. 5th and select "Update this and future occurrences only" - The edited event (5th) keeps repeating 10 times instead of ending on the end date of the original event (10th Jan). This is not consistent with other calendars (except nextcloud). The fix: Count the occurrence number starting from the first event and subtract it from the total number of repetitions before saving the event
This commit is contained in:
parent
861bb423c5
commit
d0f88c1099
1 changed files with 14 additions and 5 deletions
|
@ -1376,13 +1376,22 @@ class EventActivity : SimpleActivity() {
|
|||
}
|
||||
EDIT_FUTURE_OCCURRENCES -> {
|
||||
ensureBackgroundThread {
|
||||
eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS)
|
||||
mEvent.apply {
|
||||
id = null
|
||||
val eventId = mEvent.id!!
|
||||
val originalEvent = eventsDB.getEventWithId(eventId) ?: return@ensureBackgroundThread
|
||||
val hasFixedRepeatCount = originalEvent.repeatLimit < 0 && mEvent.repeatLimit < 0
|
||||
val repeatLimitUnchanged = originalEvent.repeatLimit == mEvent.repeatLimit
|
||||
if (hasFixedRepeatCount && repeatLimitUnchanged) {
|
||||
val daysSinceStart = (mEventOccurrenceTS - originalEvent.startTS) / DAY
|
||||
val newRepeatLimit = mEvent.repeatLimit + daysSinceStart
|
||||
mEvent.repeatLimit = newRepeatLimit
|
||||
}
|
||||
|
||||
eventsHelper.insertEvent(mEvent, addToCalDAV = true, showToasts = true) {
|
||||
finish()
|
||||
mEvent.id = null
|
||||
eventsHelper.apply {
|
||||
addEventRepeatLimit(eventId, mEventOccurrenceTS)
|
||||
insertEvent(mEvent, addToCalDAV = true, showToasts = true) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue