diff --git a/Mac/Preferences/Accounts/AccountsAddCloudKitWindowController.swift b/Mac/Preferences/Accounts/AccountsAddCloudKitWindowController.swift index 388e7af20..fdb0797d8 100644 --- a/Mac/Preferences/Accounts/AccountsAddCloudKitWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsAddCloudKitWindowController.swift @@ -17,7 +17,7 @@ enum AccountsAddCloudKitWindowControllerError: LocalizedError { } } -class AccountsAddCloudKitWindowController: NSWindowController { +final class AccountsAddCloudKitWindowController: NSWindowController { private weak var hostWindow: NSWindow? @@ -31,9 +31,9 @@ class AccountsAddCloudKitWindowController: NSWindowController { // MARK: API - func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) { + func runSheetOnWindow(_ hostWindow: NSWindow) async -> NSApplication.ModalResponse { self.hostWindow = hostWindow - hostWindow.beginSheet(window!, completionHandler: completion) + return await hostWindow.beginSheet(window!) } // MARK: Actions @@ -51,5 +51,4 @@ class AccountsAddCloudKitWindowController: NSWindowController { let _ = AccountManager.shared.createAccount(type: .cloudKit) hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK) } - } diff --git a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift index d2b449b2f..0b7591905 100644 --- a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift +++ b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift @@ -159,11 +159,14 @@ extension AccountsPreferencesViewController: AccountsPreferencesAddAccountDelega addAccountWindowController = accountsAddLocalWindowController case .cloudKit: let accountsAddCloudKitWindowController = AccountsAddCloudKitWindowController() - accountsAddCloudKitWindowController.runSheetOnWindow(self.view.window!) { response in + + Task { @MainActor in + let response = await accountsAddCloudKitWindowController.runSheetOnWindow(self.view.window!) if response == NSApplication.ModalResponse.OK { self.tableView.reloadData() } } + addAccountWindowController = accountsAddCloudKitWindowController case .feedbin: let accountsFeedbinWindowController = AccountsFeedbinWindowController()