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:
parent
cfd1b16801
commit
3428bfbc9e
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue