aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift8
1 files changed, 6 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
index 7a6a4a06..27d60c7c 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
@@ -84,7 +84,8 @@ class TunnelEditViewController: NSViewController {
weak var delegate: TunnelEditViewControllerDelegate?
- var textViewObservationToken: AnyObject?
+ var privateKeyObservationToken: AnyObject?
+ var hasErrorObservationToken: AnyObject?
init(tunnelsManager: TunnelsManager, tunnel: TunnelContainer?) {
self.tunnelsManager = tunnelsManager
@@ -119,7 +120,7 @@ class TunnelEditViewController: NSViewController {
textView.string = bootstrappingText
selectedActivateOnDemandOption = .none
}
- textViewObservationToken = textView.observe(\.privateKeyString) { [weak publicKeyRow] textView, _ in
+ privateKeyObservationToken = textView.observe(\.privateKeyString) { [weak publicKeyRow] textView, _ in
if let privateKeyString = textView.privateKeyString,
let privateKey = Data(base64Encoded: privateKeyString),
privateKey.count == TunnelConfiguration.keyLength {
@@ -129,6 +130,9 @@ class TunnelEditViewController: NSViewController {
publicKeyRow?.value = ""
}
}
+ hasErrorObservationToken = textView.observe(\.hasError) { [weak saveButton] textView, _ in
+ saveButton?.isEnabled = !textView.hasError
+ }
onDemandRow.valueOptions = activateOnDemandOptions.map { TunnelViewModel.activateOnDemandOptionText(for: $0) }
onDemandRow.selectedOptionIndex = activateOnDemandOptions.firstIndex(of: selectedActivateOnDemandOption)!