Fix endpoints not reloaded on preset change

This commit is contained in:
Davide De Rosa 2021-07-30 17:27:06 +02:00
parent 7142b556f2
commit f0aa0d0249
2 changed files with 13 additions and 1 deletions

View File

@ -55,6 +55,10 @@ class EndpointViewController: NSViewController, ProfileCustomization {
labelAddressCaption.stringValue = L10n.App.Endpoint.Cells.address.asCaption labelAddressCaption.stringValue = L10n.App.Endpoint.Cells.address.asCaption
labelProtocolCaption.stringValue = L10n.Core.Global.Captions.protocol.asCaption labelProtocolCaption.stringValue = L10n.Core.Global.Captions.protocol.asCaption
reloadEndpoints()
}
func reloadEndpoints() {
popupAddress.removeAllItems() popupAddress.removeAllItems()
for address in dataSource.addresses { for address in dataSource.addresses {
popupAddress.addItem(withTitle: address) popupAddress.addItem(withTitle: address)

View File

@ -58,6 +58,8 @@ class ProfileCustomizationContainerViewController: NSViewController {
@IBOutlet private weak var buttonCancel: NSButton! @IBOutlet private weak var buttonCancel: NSButton!
fileprivate weak var endpointController: EndpointViewController?
fileprivate weak var dnsController: DNSViewController? fileprivate weak var dnsController: DNSViewController?
fileprivate weak var proxyController: ProxyViewController? fileprivate weak var proxyController: ProxyViewController?
@ -184,6 +186,10 @@ extension ProfileCustomizationContainerViewController: ProfileCustomizationDeleg
func profileCustomization(_ profileCustomization: ProfileCustomization, didUpdatePreset newPreset: InfrastructurePreset) { func profileCustomization(_ profileCustomization: ProfileCustomization, didUpdatePreset newPreset: InfrastructurePreset) {
pendingPreset = newPreset pendingPreset = newPreset
// XXX: commit immediately to update endpoints
(profile as? ProviderConnectionProfile)?.presetId = newPreset.id
endpointController?.reloadEndpoints()
} }
func profileCustomization(_ profileCustomization: ProfileCustomization, didUpdateConfiguration newConfiguration: OpenVPN.ConfigurationBuilder) { func profileCustomization(_ profileCustomization: ProfileCustomization, didUpdateConfiguration newConfiguration: OpenVPN.ConfigurationBuilder) {
@ -235,7 +241,9 @@ class ProfileCustomizationViewController: NSTabViewController {
custom.profile = profile custom.profile = profile
custom.delegate = containerController 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 containerController?.dnsController = vc
} else if let vc = custom as? ProxyViewController { } else if let vc = custom as? ProxyViewController {
containerController?.proxyController = vc containerController?.proxyController = vc