Ask the server whether a home set is a calendar before offering list creation, and fix the changelog section (#180)
This commit is contained in:
1 parent
4ed54f6c7e
commit
eaa8f3ec74
6 files changed
+70
-17
No files matched your search
@@ -107,7 +107,6 @@ 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
|
||||
|
||||
@@ -234,17 +233,10 @@ 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