Skip to content

Commit

Permalink
Avoid mapping excludedEndpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
keeshux committed Dec 10, 2024
1 parent 60ef086 commit 6f9f3c1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ private final class CDModulePreferencesRepositoryV3: ModulePreferencesRepository
}
}

var excludedEndpoints: Set<ExtendedEndpoint> {
context.performAndWait {
let mapper = DomainMapper()
return mapper.excludedEndpoints(from: entity.excludedEndpoints)
}
}

func isExcludedEndpoint(_ endpoint: ExtendedEndpoint) -> Bool {
context.performAndWait {
entity.excludedEndpoints?.contains {
Expand Down
8 changes: 4 additions & 4 deletions Library/Sources/AppUIMain/Views/Modules/OpenVPNView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public final class ModulePreferences: ObservableObject {
self.repository = repository
}

public var excludedEndpoints: Set<ExtendedEndpoint> {
repository?.excludedEndpoints ?? []
public func isExcludedEndpoint(_ endpoint: ExtendedEndpoint) -> Bool {
repository?.isExcludedEndpoint(endpoint) ?? false
}

public func addExcludedEndpoint(_ endpoint: ExtendedEndpoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ extension PreferencesManager {
// MARK: - Dummy

private final class DummyModulePreferencesRepository: ModulePreferencesRepository {
let excludedEndpoints: Set<ExtendedEndpoint> = []

func isExcludedEndpoint(_ endpoint: ExtendedEndpoint) -> Bool {
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import Foundation
import PassepartoutKit

public protocol ModulePreferencesRepository {
var excludedEndpoints: Set<ExtendedEndpoint> { get }

func isExcludedEndpoint(_ endpoint: ExtendedEndpoint) -> Bool

func addExcludedEndpoint(_ endpoint: ExtendedEndpoint)
Expand Down

0 comments on commit 6f9f3c1

Please sign in to comment.