From: Roopesh Chander Date: Mon, 27 May 2019 09:11:56 +0000 (+0530) Subject: macOS: Tunnel detail: No need to update runtime info on tunnelSaved() X-Git-Tag: 0.0.20190531-9~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9faf814e8bf6c7e123150262d3e337a2e263023e;p=thirdparty%2Fwireguard-apple.git macOS: Tunnel detail: No need to update runtime info on tunnelSaved() Signed-off-by: Roopesh Chander --- 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 }