Skip to content

Commit 3a508f0

Browse files
committed
do not update remote CalDAV server at every refresh
1 parent 95ce2f9 commit 3a508f0

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

  • app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers

app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import com.simplemobiletools.calendar.pro.models.*
1414
import com.simplemobiletools.calendar.pro.objects.States.isUpdatingCalDAV
1515
import com.simplemobiletools.commons.extensions.*
1616
import com.simplemobiletools.commons.helpers.*
17-
import java.util.*
18-
import kotlin.collections.ArrayList
1917
import org.joda.time.DateTimeZone
2018
import org.joda.time.format.DateTimeFormat
19+
import java.util.*
20+
import kotlin.collections.ArrayList
2121

2222
@SuppressLint("MissingPermission")
2323
class CalDAVHelper(val context: Context) {
@@ -33,12 +33,14 @@ class CalDAVHelper(val context: Context) {
3333
val calDAVCalendars = getCalDAVCalendars(context.config.caldavSyncedCalendarIds, showToasts)
3434
for (calendar in calDAVCalendars) {
3535
val localEventType = eventsHelper.getEventTypeWithCalDAVCalendarId(calendar.id) ?: continue
36-
localEventType.apply {
37-
title = calendar.displayName
38-
caldavDisplayName = calendar.displayName
39-
caldavEmail = calendar.accountName
40-
color = calendar.color
41-
eventsHelper.insertOrUpdateEventTypeSync(this)
36+
if (calendar.displayName != localEventType.title || calendar.color != localEventType.color) {
37+
localEventType.apply {
38+
title = calendar.displayName
39+
caldavDisplayName = calendar.displayName
40+
caldavEmail = calendar.accountName
41+
color = calendar.color
42+
eventsHelper.insertOrUpdateEventTypeSync(this)
43+
}
4244
}
4345

4446
fetchCalDAVCalendarEvents(calendar.id, localEventType.id!!, showToasts)
@@ -105,7 +107,6 @@ class CalDAVHelper(val context: Context) {
105107
context.contentResolver.update(uri, values, null, null)
106108
context.eventTypesDB.insertOrUpdate(eventType)
107109
} catch (e: IllegalArgumentException) {
108-
e.printStackTrace()
109110
}
110111
}
111112

0 commit comments

Comments
 (0)