aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-09 00:52:11 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-14 14:52:35 +0530
commitfc9e2de72cd9166572b3099fe0cc8102c9f2f2d0 (patch)
tree81c4b98abd6e9ff967ef937fe385a95bdd350578 /WireGuard/WireGuard/UI
parentmacOS: Edit view: Update public key as you edit (diff)
downloadwireguard-apple-fc9e2de72cd9166572b3099fe0cc8102c9f2f2d0.tar.xz
wireguard-apple-fc9e2de72cd9166572b3099fe0cc8102c9f2f2d0.zip
macOS: Update detail view after editing
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift12
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift9
2 files changed, 21 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
index 9e84e12..3c07060 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
@@ -192,6 +192,7 @@ class TunnelDetailTableViewController: NSViewController {
@objc func editButtonClicked() {
let tunnelEditVC = TunnelEditViewController(tunnelsManager: tunnelsManager, tunnel: tunnel)
+ tunnelEditVC.delegate = self
presentAsSheet(tunnelEditVC)
}
@@ -234,3 +235,14 @@ extension TunnelDetailTableViewController: NSTableViewDelegate {
}
}
}
+
+extension TunnelDetailTableViewController: TunnelEditViewControllerDelegate {
+ func tunnelSaved(tunnel: TunnelContainer) {
+ tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
+ tableView.reloadData()
+ }
+
+ func tunnelEditingCancelled() {
+ // Nothing to do
+ }
+}
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
index d8dbbd2..62eba17 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
@@ -3,6 +3,11 @@
import Cocoa
+protocol TunnelEditViewControllerDelegate: class {
+ func tunnelSaved(tunnel: TunnelContainer)
+ func tunnelEditingCancelled()
+}
+
class TunnelEditViewController: NSViewController {
let nameRow: EditableKeyValueRow = {
@@ -62,6 +67,8 @@ class TunnelEditViewController: NSViewController {
let tunnelsManager: TunnelsManager
let tunnel: TunnelContainer?
+ weak var delegate: TunnelEditViewControllerDelegate?
+
var textViewObservationToken: AnyObject?
init(tunnelsManager: TunnelsManager, tunnel: TunnelContainer?) {
@@ -149,6 +156,7 @@ class TunnelEditViewController: NSViewController {
return
}
self?.dismiss(self)
+ self?.delegate?.tunnelSaved(tunnel: tunnel)
}
} catch let error as WireGuardAppError {
ErrorPresenter.showErrorAlert(error: error, from: self)
@@ -159,6 +167,7 @@ class TunnelEditViewController: NSViewController {
}
@objc func discardButtonClicked() {
+ delegate?.tunnelEditingCancelled()
dismiss(self)
}
}