Don't allow the creation of iCloud accounts if iCloud and iCloud Drive aren't enabled. Fixes #3106
This commit is contained in:
parent
7a28353358
commit
d6aa5f23ba
@ -9,6 +9,14 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Account
|
import Account
|
||||||
|
|
||||||
|
enum AccountsAddCloudKitWindowControllerError: LocalizedError {
|
||||||
|
case iCloudDriveMissing
|
||||||
|
|
||||||
|
var errorDescription: String? {
|
||||||
|
return NSLocalizedString("Unable to add iCloud Account. Please make sure you have iCloud and iCloud enabled in System Preferences.", comment: "Unable to add iCloud Account.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class AccountsAddCloudKitWindowController: NSWindowController {
|
class AccountsAddCloudKitWindowController: NSWindowController {
|
||||||
|
|
||||||
private weak var hostWindow: NSWindow?
|
private weak var hostWindow: NSWindow?
|
||||||
@ -35,6 +43,11 @@ class AccountsAddCloudKitWindowController: NSWindowController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func create(_ sender: Any) {
|
@IBAction func create(_ sender: Any) {
|
||||||
|
guard FileManager.default.ubiquityIdentityToken != nil else {
|
||||||
|
NSApplication.shared.presentError(AccountsAddCloudKitWindowControllerError.iCloudDriveMissing)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let _ = AccountManager.shared.createAccount(type: .cloudKit)
|
let _ = AccountManager.shared.createAccount(type: .cloudKit)
|
||||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,14 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Account
|
import Account
|
||||||
|
|
||||||
|
enum CloudKitAccountViewControllerError: LocalizedError {
|
||||||
|
case iCloudDriveMissing
|
||||||
|
|
||||||
|
var errorDescription: String? {
|
||||||
|
return NSLocalizedString("Unable to add iCloud Account. Please make sure you have iCloud and iCloud enabled in System Preferences.", comment: "Unable to add iCloud Account.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class CloudKitAccountViewController: UITableViewController {
|
class CloudKitAccountViewController: UITableViewController {
|
||||||
|
|
||||||
weak var delegate: AddAccountDismissDelegate?
|
weak var delegate: AddAccountDismissDelegate?
|
||||||
@ -31,6 +39,11 @@ class CloudKitAccountViewController: UITableViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func add(_ sender: Any) {
|
@IBAction func add(_ sender: Any) {
|
||||||
|
guard FileManager.default.ubiquityIdentityToken != nil else {
|
||||||
|
presentError(CloudKitAccountViewControllerError.iCloudDriveMissing)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let _ = AccountManager.shared.createAccount(type: .cloudKit)
|
let _ = AccountManager.shared.createAccount(type: .cloudKit)
|
||||||
dismiss(animated: true, completion: nil)
|
dismiss(animated: true, completion: nil)
|
||||||
delegate?.dismiss()
|
delegate?.dismiss()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user