Add iCloudAccount computed property to eliminate duplication of code that filters for it.

This commit is contained in:
Brent Simmons committed 2026-03-21 13:34:55 -07:00
1 parent c8be0704a0
commit 7c7b2b04ea
1 file changed
+6 -7
@@ -59,13 +59,12 @@ import ErrorLog
sortByName(accounts)
}
public var iCloudAccount: Account? {
accounts.first(where: { $0.type == .cloudKit })
}
public var hasiCloudAccount: Bool {
for account in accounts {
if account.type == .cloudKit {
return true
}
}
return false
iCloudAccount != nil
}
public var activeAccounts: [Account] {
@@ -148,7 +147,7 @@ import ErrorLog
public func createAccount(type: AccountType) -> Account {
if type == .cloudKit {
if let existingiCloudAccount = accounts.first(where: { $0.type == .cloudKit }) {
if let existingiCloudAccount = iCloudAccount {
return existingiCloudAccount
}
}