From 3a508f05ce63384c0eeadfe8a93ba28d234eca69 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 1 Jan 2022 23:00:57 +0100 Subject: [PATCH] do not update remote CalDAV server at every refresh --- .../calendar/pro/helpers/CalDAVHelper.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index 0e8c98ca2..510d351c6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -14,10 +14,10 @@ import com.simplemobiletools.calendar.pro.models.* import com.simplemobiletools.calendar.pro.objects.States.isUpdatingCalDAV import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* -import java.util.* -import kotlin.collections.ArrayList import org.joda.time.DateTimeZone import org.joda.time.format.DateTimeFormat +import java.util.* +import kotlin.collections.ArrayList @SuppressLint("MissingPermission") class CalDAVHelper(val context: Context) { @@ -33,12 +33,14 @@ class CalDAVHelper(val context: Context) { val calDAVCalendars = getCalDAVCalendars(context.config.caldavSyncedCalendarIds, showToasts) for (calendar in calDAVCalendars) { val localEventType = eventsHelper.getEventTypeWithCalDAVCalendarId(calendar.id) ?: continue - localEventType.apply { - title = calendar.displayName - caldavDisplayName = calendar.displayName - caldavEmail = calendar.accountName - color = calendar.color - eventsHelper.insertOrUpdateEventTypeSync(this) + if (calendar.displayName != localEventType.title || calendar.color != localEventType.color) { + localEventType.apply { + title = calendar.displayName + caldavDisplayName = calendar.displayName + caldavEmail = calendar.accountName + color = calendar.color + eventsHelper.insertOrUpdateEventTypeSync(this) + } } fetchCalDAVCalendarEvents(calendar.id, localEventType.id!!, showToasts) @@ -105,7 +107,6 @@ class CalDAVHelper(val context: Context) { context.contentResolver.update(uri, values, null, null) context.eventTypesDB.insertOrUpdate(eventType) } catch (e: IllegalArgumentException) { - e.printStackTrace() } }