From f0aa0d02498ec3c51b1f861362bc4bce9e8e20a6 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 30 Jul 2021 17:27:06 +0200 Subject: [PATCH] Fix endpoints not reloaded on preset change --- .../Service/Customization/EndpointViewController.swift | 4 ++++ .../ProfileCustomizationViewController.swift | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Passepartout/App/macOS/Scenes/Service/Customization/EndpointViewController.swift b/Passepartout/App/macOS/Scenes/Service/Customization/EndpointViewController.swift index 96762a12..78d5c904 100644 --- a/Passepartout/App/macOS/Scenes/Service/Customization/EndpointViewController.swift +++ b/Passepartout/App/macOS/Scenes/Service/Customization/EndpointViewController.swift @@ -55,6 +55,10 @@ class EndpointViewController: NSViewController, ProfileCustomization { labelAddressCaption.stringValue = L10n.App.Endpoint.Cells.address.asCaption labelProtocolCaption.stringValue = L10n.Core.Global.Captions.protocol.asCaption + reloadEndpoints() + } + + func reloadEndpoints() { popupAddress.removeAllItems() for address in dataSource.addresses { popupAddress.addItem(withTitle: address) diff --git a/Passepartout/App/macOS/Scenes/Service/Customization/ProfileCustomizationViewController.swift b/Passepartout/App/macOS/Scenes/Service/Customization/ProfileCustomizationViewController.swift index 537ac0b7..a585e7da 100644 --- a/Passepartout/App/macOS/Scenes/Service/Customization/ProfileCustomizationViewController.swift +++ b/Passepartout/App/macOS/Scenes/Service/Customization/ProfileCustomizationViewController.swift @@ -58,6 +58,8 @@ class ProfileCustomizationContainerViewController: NSViewController { @IBOutlet private weak var buttonCancel: NSButton! + fileprivate weak var endpointController: EndpointViewController? + fileprivate weak var dnsController: DNSViewController? fileprivate weak var proxyController: ProxyViewController? @@ -184,6 +186,10 @@ extension ProfileCustomizationContainerViewController: ProfileCustomizationDeleg func profileCustomization(_ profileCustomization: ProfileCustomization, didUpdatePreset newPreset: InfrastructurePreset) { pendingPreset = newPreset + + // XXX: commit immediately to update endpoints + (profile as? ProviderConnectionProfile)?.presetId = newPreset.id + endpointController?.reloadEndpoints() } func profileCustomization(_ profileCustomization: ProfileCustomization, didUpdateConfiguration newConfiguration: OpenVPN.ConfigurationBuilder) { @@ -235,7 +241,9 @@ class ProfileCustomizationViewController: NSTabViewController { custom.profile = profile custom.delegate = containerController - if let vc = custom as? DNSViewController { + if let vc = custom as? EndpointViewController { + containerController?.endpointController = vc + } else if let vc = custom as? DNSViewController { containerController?.dnsController = vc } else if let vc = custom as? ProxyViewController { containerController?.proxyController = vc