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
commit9faf814e8bf6c7e123150262d3e337a2e263023e (patch)
tree8662bf9b9bdf215eac10b6447f09e3497214b468
parentmacOS: Start refreshing runtime info in viewWillAppear(), not init() (diff)
downloadwireguard-apple-9faf814e8bf6c7e123150262d3e337a2e263023e.tar.xz
wireguard-apple-9faf814e8bf6c7e123150262d3e337a2e263023e.zip
macOS: Tunnel detail: No need to update runtime info on tunnelSaved()
Signed-off-by: Roopesh Chander <roop@roopc.net>
-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
}