update caldav calendar data at refreshing events too
This commit is contained in:
parent
c88ccbe83f
commit
c1a59f36a7
|
@ -22,8 +22,20 @@ import kotlin.collections.ArrayList
|
|||
|
||||
class CalDAVHandler(val context: Context) {
|
||||
fun refreshCalendars(callback: () -> Unit) {
|
||||
val dbHelper = context.dbHelper
|
||||
getCalDAVCalendars(context.config.caldavSyncedCalendarIDs).forEach {
|
||||
val eventTypeId = context.dbHelper.getEventTypeIdWithTitle(it.getFullTitle())
|
||||
val localEventTypeId = dbHelper.getEventTypeIdWithCalDAVCalendarId(it.id)
|
||||
if (localEventTypeId != -1) {
|
||||
dbHelper.getEventType(localEventTypeId)?.apply {
|
||||
title = it.displayName
|
||||
caldavDisplayName = it.displayName
|
||||
caldavEmail = it.accountName
|
||||
color = it.color
|
||||
dbHelper.updateLocalEventType(this)
|
||||
}
|
||||
}
|
||||
|
||||
val eventTypeId = dbHelper.getEventTypeIdWithTitle(it.getFullTitle())
|
||||
CalDAVHandler(context).fetchCalDAVCalendarEvents(it.id, eventTypeId)
|
||||
}
|
||||
context.scheduleCalDAVSync(true)
|
||||
|
|
|
@ -289,7 +289,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateLocalEventType(eventType: EventType): Int {
|
||||
fun updateLocalEventType(eventType: EventType): Int {
|
||||
val selectionArgs = arrayOf(eventType.id.toString())
|
||||
val values = fillEventTypeValues(eventType)
|
||||
val selection = "$COL_TYPE_ID = ?"
|
||||
|
|
Loading…
Reference in New Issue