From f5c0a29650729f1702ec2b881f3852ce90e1faed Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 10 Dec 2020 14:21:22 -0600 Subject: [PATCH] Restrict types of accounts that can be added based on Developer build flag. Issue #2663 --- Account/Sources/Account/Account.swift | 5 ++++ .../Accounts/AddAccountHelpView.swift | 29 ++++++++++--------- .../Accounts/AddAccountsView.swift | 8 +++-- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Account/Sources/Account/Account.swift b/Account/Sources/Account/Account.swift index 86ea89176..ec82c4225 100644 --- a/Account/Sources/Account/Account.swift +++ b/Account/Sources/Account/Account.swift @@ -45,6 +45,11 @@ public enum AccountType: Int, Codable { case inoreader = 21 case bazQux = 22 case theOldReader = 23 + + public var isDeveloperRestricted: Bool { + return self == .cloudKit || self == .feedbin || self == .feedly || self == .feedWrangler || self == .inoreader + } + } public enum FetchType { diff --git a/Mac/Preferences/Accounts/AddAccountHelpView.swift b/Mac/Preferences/Accounts/AddAccountHelpView.swift index 48dbab52d..4fa1fd54a 100644 --- a/Mac/Preferences/Accounts/AddAccountHelpView.swift +++ b/Mac/Preferences/Accounts/AddAccountHelpView.swift @@ -19,19 +19,21 @@ struct AddAccountHelpView: View { var body: some View { VStack { HStack { - ForEach(accountTypes, id: \.self) { account in - Button(action: { - if account == .cloudKit && AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) { - iCloudUnavailableError = true - } else { - delegate?.presentSheetForAccount(account) - } - }, label: { - account.image() - .resizable() - .frame(width: 20, height: 20, alignment: .center) - }) - .buttonStyle(PlainButtonStyle()) + ForEach(accountTypes, id: \.self) { accountType in + 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) + } + }, label: { + accountType.image() + .resizable() + .frame(width: 20, height: 20, alignment: .center) + }) + .buttonStyle(PlainButtonStyle()) + } } } @@ -48,4 +50,5 @@ struct AddAccountHelpView: View { })) }) } + } diff --git a/Mac/Preferences/Accounts/AddAccountsView.swift b/Mac/Preferences/Accounts/AddAccountsView.swift index 00c958c72..60cfd25b3 100644 --- a/Mac/Preferences/Accounts/AddAccountsView.swift +++ b/Mac/Preferences/Accounts/AddAccountsView.swift @@ -86,7 +86,11 @@ struct AddAccountsView: View { .padding() localAccount - icloudAccount + + if !AppDefaults.shared.isDeveloperBuild { + icloudAccount + } + webAccounts selfhostedAccounts @@ -265,7 +269,7 @@ struct AddAccountsView: View { } private func isRestricted(_ accountType: AccountType) -> Bool { - if AppDefaults.shared.isDeveloperBuild && (accountType == .feedly || accountType == .feedWrangler || accountType == .inoreader) { + if AppDefaults.shared.isDeveloperBuild && accountType.isDeveloperRestricted { return true } return false