Restrict types of accounts that can be added based on Developer build flag. Issue #2663

This commit is contained in:
Maurice Parker 2020-12-10 14:21:22 -06:00
parent 2a3f41cbbf
commit f5c0a29650
3 changed files with 27 additions and 15 deletions

View File

@ -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 {

View File

@ -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 {
}))
})
}
}

View File

@ -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