aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift18
1 files changed, 7 insertions, 11 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
index 5158b37..eafa88f 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
@@ -102,7 +102,13 @@ class TunnelDetailTableViewController: NSViewController {
updateTableViewModelRowsBySection()
updateTableViewModelRows()
statusObservationToken = tunnel.observe(\TunnelContainer.status) { [weak self] _, _ in
- self?.updateStatus()
+ guard let self = self else { return }
+ if tunnel.status == .active {
+ self.startUpdatingRuntimeConfiguration()
+ } else if tunnel.status == .inactive {
+ self.reloadRuntimeConfiguration()
+ self.stopUpdatingRuntimeConfiguration()
+ }
}
}
@@ -199,15 +205,6 @@ class TunnelDetailTableViewController: NSViewController {
tableViewModelRows = tableViewModelRowsBySection.flatMap { $0.filter { $0.isVisible }.map { $0.modelRow } }
}
- func updateStatus() {
- if tunnel.status == .active {
- startUpdatingRuntimeConfiguration()
- } else if tunnel.status == .inactive {
- reloadRuntimeConfiguration()
- stopUpdatingRuntimeConfiguration()
- }
- }
-
@objc func handleEditTunnelAction() {
PrivateDataConfirmation.confirmAccess(to: tr("macViewPrivateData")) { [weak self] in
guard let self = self else { return }
@@ -508,7 +505,6 @@ extension TunnelDetailTableViewController: TunnelEditViewControllerDelegate {
onDemandViewModel = ActivateOnDemandViewModel(tunnel: tunnel)
updateTableViewModelRowsBySection()
updateTableViewModelRows()
- updateStatus()
tableView.reloadData()
self.tunnelEditVC = nil
}