diff --git a/Mac/Preferences/Accounts/AccountsDeleteWindowController.swift b/Mac/Preferences/Accounts/AccountsDeleteWindowController.swift index 16a0d1295..ff03d6b7e 100644 --- a/Mac/Preferences/Accounts/AccountsDeleteWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsDeleteWindowController.swift @@ -28,9 +28,9 @@ class AccountsDeleteWindowController: NSWindowController { // MARK: API - func runSheetOnWindow(_ hostWindow: NSWindow) { + func runSheetOnWindow(_ hostWindow: NSWindow, completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil) { self.hostWindow = hostWindow - hostWindow.beginSheet(window!) + hostWindow.beginSheet(window!, completionHandler: handler) } // MARK: Actions diff --git a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift index 162d01c37..41ed2accd 100644 --- a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift +++ b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift @@ -38,12 +38,19 @@ final class AccountsPreferencesViewController: NSViewController { } @IBAction func removeAccount(_ sender: Any) { + guard tableView.selectedRow != -1 else { return } + let account = sortedAccounts[tableView.selectedRow] deleteController = AccountsDeleteWindowController(account: account) - deleteController!.runSheetOnWindow(view.window!) + deleteController!.runSheetOnWindow(view.window!) { [weak self] result in + if result == NSApplication.ModalResponse.OK { + self?.showController(AccountsAddViewController()) + } + } + } @objc func displayNameDidChange(_ note: Notification) {