Skip to content

Commit a1d0ce8

Browse files
sunkuprfc2822
authored andcommitted
Set default sync interval for address book authority again
1 parent 2e0c0b0 commit a1d0ce8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

app/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class AccountRepository @Inject constructor(
8585
val defaultSyncInterval = settingsManager.getLong(Settings.DEFAULT_SYNC_INTERVAL)
8686

8787
// Configure CardDAV service
88+
val addrBookAuthority = context.getString(R.string.address_books_authority)
8889
if (config.cardDAV != null) {
8990
// insert CardDAV service
9091
val id = insertService(accountName, Service.TYPE_CARDDAV, config.cardDAV)
@@ -94,6 +95,9 @@ class AccountRepository @Inject constructor(
9495

9596
// start CardDAV service detection (refresh collections)
9697
RefreshCollectionsWorker.enqueue(context, id)
98+
99+
// set default sync interval for address books
100+
accountSettings.setSyncInterval(addrBookAuthority, defaultSyncInterval)
97101
}
98102

99103
// Configure CalDAV service

app/src/main/kotlin/at/bitfire/davdroid/settings/AccountSettings.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,14 @@ class AccountSettings(
217217
* @return sync interval in seconds; *[SYNC_INTERVAL_MANUALLY]* if manual sync; *null* if not set
218218
*/
219219
fun getSyncInterval(authority: String): Long? {
220-
if (ContentResolver.getIsSyncable(account, authority) <= 0)
220+
val addrBookAuthority = context.getString(R.string.address_books_authority)
221+
222+
if (ContentResolver.getIsSyncable(account, authority) <= 0
223+
&& authority != addrBookAuthority)
221224
return null
222225

223226
val key = when {
224-
authority == context.getString(R.string.address_books_authority) ->
227+
authority == addrBookAuthority ->
225228
KEY_SYNC_INTERVAL_ADDRESSBOOKS
226229
authority == CalendarContract.AUTHORITY ->
227230
KEY_SYNC_INTERVAL_CALENDARS

0 commit comments

Comments
 (0)