aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-05-27 14:41:56 +0530
committerRoopesh Chander <roop@roopc.net>2019-05-27 14:43:41 +0530
commit87a28b8c8021465ff6e3eb27b93d5572dcee4c9f (patch)
tree8662bf9b9bdf215eac10b6447f09e3497214b468
parentmacOS: Start refreshing runtime info in viewWillAppear(), not init() (diff)
downloadwireguard-apple-87a28b8c8021465ff6e3eb27b93d5572dcee4c9f.tar.xz
wireguard-apple-87a28b8c8021465ff6e3eb27b93d5572dcee4c9f.zip
macOS: Tunnel detail: No need to update runtime info on tunnelSaved()
-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 5158b37c..eafa88f7 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
}