macOS: Select tunnel after adding it with 'Add empty tunnel'

This commit is contained in:
Roopesh Chander 2019-02-05 16:39:19 +05:30
parent 6838d19599
commit d3a4d606cf
1 changed files with 13 additions and 0 deletions

View File

@ -141,6 +141,7 @@ class TunnelsListTableViewController: NSViewController {
@objc func handleAddEmptyTunnelAction() {
let tunnelEditVC = TunnelEditViewController(tunnelsManager: tunnelsManager, tunnel: nil)
tunnelEditVC.delegate = self
presentAsSheet(tunnelEditVC)
}
@ -237,6 +238,18 @@ class TunnelsListTableViewController: NSViewController {
}
}
extension TunnelsListTableViewController: TunnelEditViewControllerDelegate {
func tunnelSaved(tunnel: TunnelContainer) {
if let tunnelIndex = tunnelsManager.index(of: tunnel), tunnelIndex >= 0 {
self.selectTunnel(at: tunnelIndex)
}
}
func tunnelEditingCancelled() {
// Nothing to do
}
}
extension TunnelsListTableViewController {
func tunnelAdded(at index: Int) {
tableView.insertRows(at: IndexSet(integer: index), withAnimation: .slideLeft)