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