mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-03 10:47:21 +00:00
Add iCloudAccount computed property to eliminate duplication of code that filters for it.
This commit is contained in:
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user