Properly handle repeat limits
Fixes these issues: - When choosing `Update/Delete this and all future occurrences`, the selected occurrence is never deleted/updated. - When choosing `Update this and all future occurrences`, the event is duplicated on the date of the selection
This commit is contained in:
parent
d0f88c1099
commit
46e17aa697
2 changed files with 19 additions and 4 deletions
|
@ -225,9 +225,17 @@ class EventsHelper(val context: Context) {
|
|||
deleteEvents(eventIds, true)
|
||||
}
|
||||
|
||||
fun addEventRepeatLimit(eventId: Long, limitTS: Long) {
|
||||
val time = Formatter.getDateTimeFromTS(limitTS)
|
||||
eventsDB.updateEventRepetitionLimit(limitTS - time.hourOfDay, eventId)
|
||||
fun addEventRepeatLimit(eventId: Long, occurrenceTS: Long) {
|
||||
val event = eventsDB.getEventWithId(eventId) ?: return
|
||||
val previousOccurrenceTS = occurrenceTS - event.repeatInterval // always update repeat limit of the occurrence preceding the one being edited
|
||||
val repeatLimitDateTime = Formatter.getDateTimeFromTS(previousOccurrenceTS).withTimeAtStartOfDay()
|
||||
val repeatLimitTS = if (event.getIsAllDay()) {
|
||||
repeatLimitDateTime.seconds()
|
||||
} else {
|
||||
repeatLimitDateTime.withTime(23, 59, 59, 0).seconds()
|
||||
}
|
||||
|
||||
eventsDB.updateEventRepetitionLimit(repeatLimitTS, eventId)
|
||||
context.cancelNotification(eventId)
|
||||
context.cancelPendingIntent(eventId)
|
||||
if (config.caldavSync) {
|
||||
|
|
|
@ -145,7 +145,14 @@ class Parser {
|
|||
private fun getRepeatLimitString(event: Event) = when {
|
||||
event.repeatLimit == 0L -> ""
|
||||
event.repeatLimit < 0 -> ";$COUNT=${-event.repeatLimit}"
|
||||
else -> ";$UNTIL=${Formatter.getDayCodeFromTS(event.repeatLimit)}"
|
||||
else -> if (event.getIsAllDay()) {
|
||||
";$UNTIL=${Formatter.getDayCodeFromTS(event.repeatLimit)}"
|
||||
} else {
|
||||
val dateTime = Formatter.getUTCDateTimeFromTS(event.repeatLimit)
|
||||
val dayCode = dateTime.toString(Formatter.DAYCODE_PATTERN)
|
||||
val timeCode = dateTime.toString(Formatter.TIME_PATTERN)
|
||||
";$UNTIL=${dayCode}T${timeCode}Z"
|
||||
}
|
||||
}
|
||||
|
||||
private fun getByMonth(event: Event) = when {
|
||||
|
|
Loading…
Reference in a new issue