From c25680ca5dad8437fd39371b5591f8662635fca8 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 2 May 2019 06:57:45 -0500 Subject: [PATCH] Show add account after delete account --- .../Accounts/AccountsDeleteWindowController.swift | 4 ++-- .../Accounts/AccountsPreferencesViewController.swift | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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) {