do not update remote CalDAV server at every refresh

This commit is contained in:
tibbi
2022-01-01 23:00:57 +01:00
parent 95ce2f9858
commit 3a508f05ce

View File

@@ -14,10 +14,10 @@ import com.simplemobiletools.calendar.pro.models.*
import com.simplemobiletools.calendar.pro.objects.States.isUpdatingCalDAV import com.simplemobiletools.calendar.pro.objects.States.isUpdatingCalDAV
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import java.util.*
import kotlin.collections.ArrayList
import org.joda.time.DateTimeZone import org.joda.time.DateTimeZone
import org.joda.time.format.DateTimeFormat import org.joda.time.format.DateTimeFormat
import java.util.*
import kotlin.collections.ArrayList
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
class CalDAVHelper(val context: Context) { class CalDAVHelper(val context: Context) {
@@ -33,12 +33,14 @@ class CalDAVHelper(val context: Context) {
val calDAVCalendars = getCalDAVCalendars(context.config.caldavSyncedCalendarIds, showToasts) val calDAVCalendars = getCalDAVCalendars(context.config.caldavSyncedCalendarIds, showToasts)
for (calendar in calDAVCalendars) { for (calendar in calDAVCalendars) {
val localEventType = eventsHelper.getEventTypeWithCalDAVCalendarId(calendar.id) ?: continue val localEventType = eventsHelper.getEventTypeWithCalDAVCalendarId(calendar.id) ?: continue
localEventType.apply { if (calendar.displayName != localEventType.title || calendar.color != localEventType.color) {
title = calendar.displayName localEventType.apply {
caldavDisplayName = calendar.displayName title = calendar.displayName
caldavEmail = calendar.accountName caldavDisplayName = calendar.displayName
color = calendar.color caldavEmail = calendar.accountName
eventsHelper.insertOrUpdateEventTypeSync(this) color = calendar.color
eventsHelper.insertOrUpdateEventTypeSync(this)
}
} }
fetchCalDAVCalendarEvents(calendar.id, localEventType.id!!, showToasts) fetchCalDAVCalendarEvents(calendar.id, localEventType.id!!, showToasts)
@@ -105,7 +107,6 @@ class CalDAVHelper(val context: Context) {
context.contentResolver.update(uri, values, null, null) context.contentResolver.update(uri, values, null, null)
context.eventTypesDB.insertOrUpdate(eventType) context.eventTypesDB.insertOrUpdate(eventType)
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
e.printStackTrace()
} }
} }