Only offer a calendar home set as a list when it holds no collections, and don't create lists inside it (#180)
This commit is contained in:
1 parent
220c18170f
commit
4ed54f6c7e
3 files changed
+37
-8
No files matched your search
@@ -107,6 +107,7 @@ class RemoteListRepository @Inject constructor(
|
||||
val homeSet = account.homeSetUrl?.toHttpUrlOrNull()
|
||||
?: return@withContext Outcome.NoAccount
|
||||
val admin = adminFor(account) ?: return@withContext Outcome.NoAccount
|
||||
if (homeSetIsAList(account)) return@withContext Outcome.Unsupported
|
||||
val capabilities = support.refresh(accountId) { admin.support(homeSet) }
|
||||
if (!capabilities.canCreate) return@withContext Outcome.Unsupported
|
||||
|
||||
@@ -233,10 +234,17 @@ class RemoteListRepository @Inject constructor(
|
||||
|
||||
private suspend fun supportFor(account: AccountEntity): CollectionSupport {
|
||||
val homeSet = account.homeSetUrl?.toHttpUrlOrNull() ?: return CollectionSupport.NONE
|
||||
if (homeSetIsAList(account)) return CollectionSupport.NONE
|
||||
val admin = adminFor(account) ?: return CollectionSupport.NONE
|
||||
return support.refresh(account.id) { admin.support(homeSet) }
|
||||
}
|
||||
|
||||
/** A home set that is itself a calendar (#180) cannot hold another one. */
|
||||
private fun homeSetIsAList(account: AccountEntity): Boolean {
|
||||
val homeSet = account.homeSetUrl?.trimEnd('/') ?: return false
|
||||
return database.taskLists().syncedForAccount(account.id).any { it.href?.trimEnd('/') == homeSet }
|
||||
}
|
||||
|
||||
/**
|
||||
* Null when the account has no credential we can use — a stopped account, or
|
||||
* a restore.
|
||||
|
||||
Reference in new issue
Block a user