From 1c854b2606740630a44428fa7a9ea2a6d059b9b4 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 16 Sep 2025 14:01:05 -0700 Subject: [PATCH] =?UTF-8?q?Skip=20showing=20the=20iCloud=20account=20icon?= =?UTF-8?q?=20when=20the=20user=20already=20has=20an=20iCloud=20account.?= =?UTF-8?q?=20This=20way=20there=E2=80=99s=20no=20need=20to=20present=20an?= =?UTF-8?q?=20error.=20Fix=20#4319.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Accounts/AddAccountHelpView.swift | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/Mac/Preferences/Accounts/AddAccountHelpView.swift b/Mac/Preferences/Accounts/AddAccountHelpView.swift index 4fa1fd54a..482232507 100644 --- a/Mac/Preferences/Accounts/AddAccountHelpView.swift +++ b/Mac/Preferences/Accounts/AddAccountHelpView.swift @@ -14,19 +14,21 @@ struct AddAccountHelpView: View { let accountTypes: [AccountType] = AddAccountSections.allOrdered.sectionContent var delegate: AccountsPreferencesAddAccountDelegate? var helpText: String - @State private var iCloudUnavailableError: Bool = false - + + var hasiCloudAccount: Bool { + AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) + } + var body: some View { VStack { HStack { ForEach(accountTypes, id: \.self) { accountType in - if !(AppDefaults.shared.isDeveloperBuild && accountType.isDeveloperRestricted) { + if accountType == .cloudKit && hasiCloudAccount { + EmptyView() + } + else if !(AppDefaults.shared.isDeveloperBuild && accountType.isDeveloperRestricted) { Button(action: { - if accountType == .cloudKit && AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) { - iCloudUnavailableError = true - } else { - delegate?.presentSheetForAccount(accountType) - } + delegate?.presentSheetForAccount(accountType) }, label: { accountType.image() .resizable() @@ -40,15 +42,6 @@ struct AddAccountHelpView: View { Text(helpText) .multilineTextAlignment(.center) .padding(.top, 8) - } - .alert(isPresented: $iCloudUnavailableError, content: { - Alert(title: Text(NSLocalizedString("Error", comment: "Error")), - message: Text(NSLocalizedString("You've already set up an iCloud account.", comment: "Error")), - dismissButton: Alert.Button.cancel({ - iCloudUnavailableError = false - })) - }) } - }