mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
Convert runSheetOnWindow to async.
This commit is contained in:
parent
fba8c52b67
commit
cd7f4f7052
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user