diff --git a/Library/Sources/AppDataPreferences/Strategy/CDModulePreferencesRepositoryV3.swift b/Library/Sources/AppDataPreferences/Strategy/CDModulePreferencesRepositoryV3.swift index 8681a789c..6ca884e6c 100644 --- a/Library/Sources/AppDataPreferences/Strategy/CDModulePreferencesRepositoryV3.swift +++ b/Library/Sources/AppDataPreferences/Strategy/CDModulePreferencesRepositoryV3.swift @@ -70,13 +70,6 @@ private final class CDModulePreferencesRepositoryV3: ModulePreferencesRepository } } - var excludedEndpoints: Set { - context.performAndWait { - let mapper = DomainMapper() - return mapper.excludedEndpoints(from: entity.excludedEndpoints) - } - } - func isExcludedEndpoint(_ endpoint: ExtendedEndpoint) -> Bool { context.performAndWait { entity.excludedEndpoints?.contains { diff --git a/Library/Sources/AppUIMain/Views/Modules/OpenVPNView.swift b/Library/Sources/AppUIMain/Views/Modules/OpenVPNView.swift index bba34bdeb..9942ca595 100644 --- a/Library/Sources/AppUIMain/Views/Modules/OpenVPNView.swift +++ b/Library/Sources/AppUIMain/Views/Modules/OpenVPNView.swift @@ -211,15 +211,15 @@ private extension OpenVPNView { path.wrappedValue.removeLast() } - // reset to provider exclusions, filtered by current preset + // filter out exclusions unrelated to current server func resetExcludedEndpointsWithCurrentProviderEntity() { do { let cfg = try draft.wrappedValue.providerSelection?.configuration() editor.profile.attributes.editPreferences(inModule: module.id) { if let cfg { - $0.excludedEndpoints = modulePreferences.excludedEndpoints.filter { - cfg.remotes?.contains($0) == true - } + $0.excludedEndpoints = Set(cfg.remotes?.filter { + modulePreferences.isExcludedEndpoint($0) + } ?? []) } else { $0.excludedEndpoints = [] } diff --git a/Library/Sources/CommonLibrary/Business/ModulePreferences.swift b/Library/Sources/CommonLibrary/Business/ModulePreferences.swift index 4bc64a27e..25642affb 100644 --- a/Library/Sources/CommonLibrary/Business/ModulePreferences.swift +++ b/Library/Sources/CommonLibrary/Business/ModulePreferences.swift @@ -38,8 +38,8 @@ public final class ModulePreferences: ObservableObject { self.repository = repository } - public var excludedEndpoints: Set { - repository?.excludedEndpoints ?? [] + public func isExcludedEndpoint(_ endpoint: ExtendedEndpoint) -> Bool { + repository?.isExcludedEndpoint(endpoint) ?? false } public func addExcludedEndpoint(_ endpoint: ExtendedEndpoint) { diff --git a/Library/Sources/CommonLibrary/Business/PreferencesManager.swift b/Library/Sources/CommonLibrary/Business/PreferencesManager.swift index b69b5e2ed..ac8f662a8 100644 --- a/Library/Sources/CommonLibrary/Business/PreferencesManager.swift +++ b/Library/Sources/CommonLibrary/Business/PreferencesManager.swift @@ -58,8 +58,6 @@ extension PreferencesManager { // MARK: - Dummy private final class DummyModulePreferencesRepository: ModulePreferencesRepository { - let excludedEndpoints: Set = [] - func isExcludedEndpoint(_ endpoint: ExtendedEndpoint) -> Bool { false } diff --git a/Library/Sources/CommonLibrary/Strategy/ModulePreferencesRepository.swift b/Library/Sources/CommonLibrary/Strategy/ModulePreferencesRepository.swift index a85b1c78b..a0481589f 100644 --- a/Library/Sources/CommonLibrary/Strategy/ModulePreferencesRepository.swift +++ b/Library/Sources/CommonLibrary/Strategy/ModulePreferencesRepository.swift @@ -27,8 +27,6 @@ import Foundation import PassepartoutKit public protocol ModulePreferencesRepository { - var excludedEndpoints: Set { get } - func isExcludedEndpoint(_ endpoint: ExtendedEndpoint) -> Bool func addExcludedEndpoint(_ endpoint: ExtendedEndpoint)