mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
couple more fixes related to caldav syncing repeatable event exceptions
This commit is contained in:
@ -240,8 +240,8 @@ class CalDAVHandler(val context: Context) {
|
|||||||
val repeatRule = Parser().parseRepeatInterval(rrule, startTS)
|
val repeatRule = Parser().parseRepeatInterval(rrule, startTS)
|
||||||
val event = Event(0, startTS, endTS, title, description, reminders.getOrElse(0, { -1 }),
|
val event = Event(0, startTS, endTS, title, description, reminders.getOrElse(0, { -1 }),
|
||||||
reminders.getOrElse(1, { -1 }), reminders.getOrElse(2, { -1 }), repeatRule.repeatInterval,
|
reminders.getOrElse(1, { -1 }), reminders.getOrElse(2, { -1 }), repeatRule.repeatInterval,
|
||||||
importId, allDay, repeatRule.repeatLimit, repeatRule.repeatRule, eventTypeId, source = source,
|
importId, allDay, repeatRule.repeatLimit, repeatRule.repeatRule, eventTypeId, lastUpdated = System.currentTimeMillis(),
|
||||||
location = location)
|
source = source, location = location)
|
||||||
|
|
||||||
if (event.getIsAllDay() && endTS > startTS) {
|
if (event.getIsAllDay() && endTS > startTS) {
|
||||||
event.endTS -= DAY
|
event.endTS -= DAY
|
||||||
@ -258,17 +258,20 @@ class CalDAVHandler(val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
context.dbHelper.insert(event, false) {
|
|
||||||
importIdsMap.put(event.importId, event)
|
|
||||||
|
|
||||||
// if the event is an exception from another events repeat rule, find the original parent event
|
// if the event is an exception from another events repeat rule, find the original parent event
|
||||||
if (originalInstanceTime != 0L) {
|
if (originalInstanceTime != 0L) {
|
||||||
val parentImportId = "$source-$originalId"
|
val parentImportId = "$source-$originalId"
|
||||||
val parentEventId = context.dbHelper.getEventIdWithImportId(parentImportId)
|
val parentEventId = context.dbHelper.getEventIdWithImportId(parentImportId)
|
||||||
if (parentEventId != 0) {
|
if (parentEventId != 0) {
|
||||||
|
event.parentId = parentEventId
|
||||||
context.dbHelper.addEventRepeatException(parentEventId, (originalInstanceTime / 1000).toInt())
|
context.dbHelper.addEventRepeatException(parentEventId, (originalInstanceTime / 1000).toInt())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (title.isNotEmpty()) {
|
||||||
|
context.dbHelper.insert(event, false) {
|
||||||
|
importIdsMap.put(event.importId, event)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
|
@ -202,7 +202,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun insert(event: Event, addToCalDAV: Boolean, callback: (id: Int) -> Unit) {
|
fun insert(event: Event, addToCalDAV: Boolean, callback: (id: Int) -> Unit) {
|
||||||
if (event.startTS > event.endTS || event.title.trim().isEmpty()) {
|
if (event.startTS > event.endTS) {
|
||||||
callback(0)
|
callback(0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -577,7 +577,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
val cursor = getEventsCursor(selection, selectionArgs)
|
val cursor = getEventsCursor(selection, selectionArgs)
|
||||||
val events = fillEvents(cursor)
|
val events = fillEvents(cursor)
|
||||||
return if (events.isNotEmpty()) {
|
return if (events.isNotEmpty()) {
|
||||||
events.first().id
|
events.minBy { it.id }?.id ?: 0
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user