macOS: Tunnel edit: Handle deletion outside app

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2019-01-22 19:30:06 +05:30
parent 2677efc9bf
commit 9f362e8cb0
1 changed files with 10 additions and 1 deletions

View File

@ -84,6 +84,7 @@ class TunnelDetailTableViewController: NSViewController {
} }
private var tableViewModelRows = [TableViewModelRow]() private var tableViewModelRows = [TableViewModelRow]()
private var statusObservationToken: AnyObject? private var statusObservationToken: AnyObject?
private var tunnelEditVC: TunnelEditViewController?
init(tunnelsManager: TunnelsManager, tunnel: TunnelContainer) { init(tunnelsManager: TunnelsManager, tunnel: TunnelContainer) {
self.tunnelsManager = tunnelsManager self.tunnelsManager = tunnelsManager
@ -201,6 +202,7 @@ class TunnelDetailTableViewController: NSViewController {
let tunnelEditVC = TunnelEditViewController(tunnelsManager: tunnelsManager, tunnel: tunnel) let tunnelEditVC = TunnelEditViewController(tunnelsManager: tunnelsManager, tunnel: tunnel)
tunnelEditVC.delegate = self tunnelEditVC.delegate = self
presentAsSheet(tunnelEditVC) presentAsSheet(tunnelEditVC)
self.tunnelEditVC = tunnelEditVC
} }
@objc func handleToggleActiveStatusAction() { @objc func handleToggleActiveStatusAction() {
@ -219,6 +221,13 @@ class TunnelDetailTableViewController: NSViewController {
tunnelsManager.startDeactivation(of: tunnel) tunnelsManager.startDeactivation(of: tunnel)
} }
} }
override func viewWillDisappear() {
super.viewWillDisappear()
if let tunnelEditVC = tunnelEditVC {
dismiss(tunnelEditVC)
}
}
} }
extension TunnelDetailTableViewController: NSTableViewDataSource { extension TunnelDetailTableViewController: NSTableViewDataSource {
@ -264,6 +273,6 @@ extension TunnelDetailTableViewController: TunnelEditViewControllerDelegate {
} }
func tunnelEditingCancelled() { func tunnelEditingCancelled() {
// Nothing to do self.tunnelEditVC = nil
} }
} }