Skip to content

Commit

Permalink
Set default sync interval for address book authority again
Browse files Browse the repository at this point in the history
  • Loading branch information
sunkup committed Jul 4, 2024
1 parent 1cf3987 commit 1a5cbbb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class AccountRepository @Inject constructor(
val defaultSyncInterval = settingsManager.getLong(Settings.DEFAULT_SYNC_INTERVAL)

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

// start CardDAV service detection (refresh collections)
RefreshCollectionsWorker.enqueue(context, id)

// set default sync interval for address books
accountSettings.setSyncInterval(addrBookAuthority, defaultSyncInterval)
}

// Configure CalDAV service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,14 @@ class AccountSettings(
* @return sync interval in seconds; *[SYNC_INTERVAL_MANUALLY]* if manual sync; *null* if not set
*/
fun getSyncInterval(authority: String): Long? {
if (ContentResolver.getIsSyncable(account, authority) <= 0)
val addrBookAuthority = context.getString(R.string.address_books_authority)

if (ContentResolver.getIsSyncable(account, authority) <= 0
&& authority != addrBookAuthority)
return null

val key = when {
authority == context.getString(R.string.address_books_authority) ->
authority == addrBookAuthority ->
KEY_SYNC_INTERVAL_ADDRESSBOOKS
authority == CalendarContract.AUTHORITY ->
KEY_SYNC_INTERVAL_CALENDARS
Expand Down

0 comments on commit 1a5cbbb

Please sign in to comment.