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,12 +232,21 @@ 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.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 {
|
if tunnel.status == .inactive {
|
||||||
tunnelsManager.startActivation(of: tunnel)
|
tunnelsManager.startActivation(of: tunnel)
|
||||||
} else if tunnel.status == .active {
|
} else if tunnel.status == .active {
|
||||||
tunnelsManager.startDeactivation(of: tunnel)
|
tunnelsManager.startDeactivation(of: tunnel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
private func selectTunnel(at index: Int) -> Bool {
|
private func selectTunnel(at index: Int) -> Bool {
|
||||||
|
|
Loading…
Reference in New Issue