From 7c7b2b04ea50551dc1fbc155774164610e6ecaa7 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 21 Mar 2026 13:34:55 -0700 Subject: [PATCH] Add iCloudAccount computed property to eliminate duplication of code that filters for it. --- .../Account/Sources/Account/AccountManager.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Modules/Account/Sources/Account/AccountManager.swift b/Modules/Account/Sources/Account/AccountManager.swift index ac153c044..b9ebbb274 100644 --- a/Modules/Account/Sources/Account/AccountManager.swift +++ b/Modules/Account/Sources/Account/AccountManager.swift @@ -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 } }