aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-06-13 18:25:13 +0530
committerRoopesh Chander <roop@roopc.net>2019-06-13 22:21:31 +0530
commit96e2707cd7e2647be15216e21a2c2f98545d5ca7 (patch)
tree121cbc43e5044264d39774833e927dfa35dcb516
parentTunnelsManager: store UID on macOS for keychain availability (diff)
downloadwireguard-apple-96e2707cd7e2647be15216e21a2c2f98545d5ca7.tar.xz
wireguard-apple-96e2707cd7e2647be15216e21a2c2f98545d5ca7.zip
macOS: Tunnel detail: Handle deletion outside app, again
This was previously done in commit f281b93, but the changes in commit 1507a97 for handling deletion of multiple tunnels undid this capability.
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift9
1 files changed, 8 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
index f6d7790..0771582 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
@@ -12,7 +12,7 @@ class TunnelsListTableViewController: NSViewController {
let tunnelsManager: TunnelsManager
weak var delegate: TunnelsListTableViewControllerDelegate?
- var isRemovingTunnels = false
+ var isRemovingTunnelsFromWithinTheApp = false
let tableView: NSTableView = {
let tableView = NSTableView()
@@ -183,8 +183,10 @@ class TunnelsListTableViewController: NSViewController {
guard let self = self else { return }
self.selectTunnel(at: nextSelection)
let selectedTunnels = selectedTunnelIndices.map { self.tunnelsManager.tunnel(at: $0) }
+ self.isRemovingTunnelsFromWithinTheApp = true
self.tunnelsManager.removeMultiple(tunnels: selectedTunnels) { [weak self] error in
guard let self = self else { return }
+ self.isRemovingTunnelsFromWithinTheApp = false
defer { completion() }
if let error = error {
ErrorPresenter.showErrorAlert(error: error, from: self)
@@ -281,9 +283,14 @@ extension TunnelsListTableViewController {
}
func tunnelRemoved(at index: Int) {
+ let selectedIndices = tableView.selectedRowIndexes
+ let isSingleSelectedTunnelBeingRemoved = selectedIndices.contains(index) && selectedIndices.count == 1
tableView.removeRows(at: IndexSet(integer: index), withAnimation: .slideLeft)
if tunnelsManager.numberOfTunnels() == 0 {
delegate?.tunnelsListEmpty()
+ } else if !isRemovingTunnelsFromWithinTheApp && isSingleSelectedTunnelBeingRemoved {
+ let newSelection = min(index, tunnelsManager.numberOfTunnels() - 1)
+ tableView.selectRowIndexes(IndexSet(integer: newSelection), byExtendingSelection: false)
}
}
}