aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-22 19:23:05 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-22 19:30:21 +0530
commit2677efc9bf3fa8cb74c5dcdf4ed87ff86eaf4f0c (patch)
tree384ea73ebdade313f5a2ba08fee87b869c0b1caa /WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
parentmacOS: Handle tunnel deletions outside the app (diff)
downloadwireguard-apple-2677efc9bf3fa8cb74c5dcdf4ed87ff86eaf4f0c.tar.xz
wireguard-apple-2677efc9bf3fa8cb74c5dcdf4ed87ff86eaf4f0c.zip
macOS: Tunnel detail: Handle deletion outside app
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift9
1 files changed, 5 insertions, 4 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
index 539b4872..5ae89c44 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
@@ -155,10 +155,6 @@ class TunnelsListTableViewController: NSViewController {
ErrorPresenter.showErrorAlert(error: error, from: self)
return
}
- let tunnelIndex = min(selectedTunnelIndex, self.tunnelsManager.numberOfTunnels() - 1)
- if tunnelIndex >= 0 {
- self.selectTunnel(at: tunnelIndex)
- }
}
}
}
@@ -249,10 +245,15 @@ extension TunnelsListTableViewController {
}
func tunnelRemoved(at index: Int) {
+ let selectedTunnelIndex = tableView.selectedRow
tableView.removeRows(at: IndexSet(integer: index), withAnimation: .slideLeft)
if tunnelsManager.numberOfTunnels() == 0 {
delegate?.tunnelsListEmpty()
}
+ let tunnelIndex = min(selectedTunnelIndex, self.tunnelsManager.numberOfTunnels() - 1)
+ if tunnelIndex >= 0 {
+ self.selectTunnel(at: tunnelIndex)
+ }
}
}