UI: macOS: do on-demand ritual for clicking list item too

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-09-22 02:40:49 +02:00
parent cfd1b16801
commit 3428bfbc9e
2 changed files with 16 additions and 7 deletions

View File

@ -216,9 +216,9 @@ class TunnelDetailTableViewController: NSViewController {
} }
@objc func handleToggleActiveStatusAction() { @objc func handleToggleActiveStatusAction() {
if self.tunnel.hasOnDemandRules { if tunnel.hasOnDemandRules {
let turnOn = !self.tunnel.isActivateOnDemandEnabled let turnOn = !tunnel.isActivateOnDemandEnabled
self.tunnelsManager.setOnDemandEnabled(turnOn, on: self.tunnel) { error in tunnelsManager.setOnDemandEnabled(turnOn, on: tunnel) { error in
if error == nil && !turnOn { if error == nil && !turnOn {
self.tunnelsManager.startDeactivation(of: self.tunnel) self.tunnelsManager.startDeactivation(of: self.tunnel)
} }

View File

@ -232,10 +232,19 @@ class TunnelsListTableViewController: NSViewController {
let tunnelIndex = tableView.clickedRow let tunnelIndex = tableView.clickedRow
guard tunnelIndex >= 0 && tunnelIndex < tunnelsManager.numberOfTunnels() else { return } guard tunnelIndex >= 0 && tunnelIndex < tunnelsManager.numberOfTunnels() else { return }
let tunnel = tunnelsManager.tunnel(at: tunnelIndex) let tunnel = tunnelsManager.tunnel(at: tunnelIndex)
if tunnel.status == .inactive { if tunnel.hasOnDemandRules {
tunnelsManager.startActivation(of: tunnel) let turnOn = !tunnel.isActivateOnDemandEnabled
} else if tunnel.status == .active { tunnelsManager.setOnDemandEnabled(turnOn, on: tunnel) { error in
tunnelsManager.startDeactivation(of: tunnel) if error == nil && !turnOn {
self.tunnelsManager.startDeactivation(of: tunnel)
}
}
} else {
if tunnel.status == .inactive {
tunnelsManager.startActivation(of: tunnel)
} else if tunnel.status == .active {
tunnelsManager.startDeactivation(of: tunnel)
}
} }
} }