diff --git a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5e65bd29..ad22b172 100644 --- a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -41,7 +41,7 @@ "kind" : "remoteSourceControl", "location" : "git@github.com:passepartoutvpn/passepartoutkit-source", "state" : { - "revision" : "4fffdbde18ddaa5ab0fdfa9ee417a0f5015f59c6" + "revision" : "7b3f68b30d2c3ac434c5aaa10853bd3709c5c308" } }, { diff --git a/Passepartout/Library/Package.swift b/Passepartout/Library/Package.swift index 17bc7156..fb5622ae 100644 --- a/Passepartout/Library/Package.swift +++ b/Passepartout/Library/Package.swift @@ -28,7 +28,7 @@ let package = Package( ], dependencies: [ // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.9.0"), - .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "4fffdbde18ddaa5ab0fdfa9ee417a0f5015f59c6"), + .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "7b3f68b30d2c3ac434c5aaa10853bd3709c5c308"), // .package(path: "../../../passepartoutkit-source"), .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.9.1"), // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"), diff --git a/Passepartout/Library/Sources/AppUI/Views/Extensions/ProviderEntityViewProviding.swift b/Passepartout/Library/Sources/AppUI/Views/Extensions/ProviderEntityViewProviding.swift index 6b6dd996..898a0aaf 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Extensions/ProviderEntityViewProviding.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Extensions/ProviderEntityViewProviding.swift @@ -35,3 +35,22 @@ protocol ProviderEntityViewProviding { onSelect: @escaping (any ProviderEntity & Encodable) async throws -> Void ) -> EntityContent } + +extension ProviderEntityViewProviding where Self: ProviderCompatibleModule, EntityType.Configuration: ProviderConfigurationIdentifiable & Codable { + func vpnProviderEntityView( + with provider: ModuleMetadata.Provider, + onSelect: @escaping (any ProviderEntity & Encodable) async throws -> Void + ) -> some View { + let selectedEntity = try? provider + .entity + .map { + try providerEntity(from: $0) + } as? VPNEntity + + return VPNProviderServerCoordinator( + providerId: provider.id, + selectedEntity: selectedEntity, + onSelect: onSelect + ) + } +} diff --git a/Passepartout/Library/Sources/AppUI/Views/Modules/Extensions/OpenVPNModule+Extensions.swift b/Passepartout/Library/Sources/AppUI/Views/Modules/Extensions/OpenVPNModule+Extensions.swift index d02dbdd7..e9d4a360 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Modules/Extensions/OpenVPNModule+Extensions.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Modules/Extensions/OpenVPNModule+Extensions.swift @@ -49,16 +49,6 @@ extension OpenVPNModule: ProviderEntityViewProviding { with provider: ModuleMetadata.Provider, onSelect: @escaping (any ProviderEntity & Encodable) async throws -> Void ) -> some View { - let selectedEntity: VPNEntity? = try? provider - .entity - .map { - try providerEntity(from: $0) - } - - return VPNProviderServerCoordinator( - providerId: provider.id, - selectedEntity: selectedEntity, - onSelect: onSelect - ) + vpnProviderEntityView(with: provider, onSelect: onSelect) } } diff --git a/Passepartout/Library/Sources/AppUI/Views/Provider/ProviderContentModifier.swift b/Passepartout/Library/Sources/AppUI/Views/Provider/ProviderContentModifier.swift index d56cd608..fa546e9e 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Provider/ProviderContentModifier.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Provider/ProviderContentModifier.swift @@ -133,10 +133,7 @@ private extension ProviderContentModifier { guard let providerId else { return nil } - return providerManager.lastUpdated( - for: providerId, - configurationType: Entity.Configuration.self - ) + return providerManager.lastUpdated(for: providerId) } var lastUpdatedString: String? { @@ -171,11 +168,7 @@ private extension ProviderContentModifier { @discardableResult func refreshInfrastructure(for providerId: ProviderID) async -> Bool { do { - try await providerManager.fetchVPNInfrastructure( - from: apis, - for: providerId, - ofType: Entity.Configuration.self - ) + try await providerManager.fetchVPNInfrastructure(from: apis, for: providerId) return true } catch { pp_log(.app, .error, "Unable to refresh infrastructure: \(error)") diff --git a/Passepartout/Library/Sources/AppUI/Views/Provider/VPNProviderServerView.swift b/Passepartout/Library/Sources/AppUI/Views/Provider/VPNProviderServerView.swift index c30cc9a4..2cbd84e9 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Provider/VPNProviderServerView.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Provider/VPNProviderServerView.swift @@ -73,8 +73,7 @@ struct VPNProviderServerView: View where Configuration: ProviderC do { manager.repository = try await providerManager.vpnRepository( from: apis, - for: providerId, - configurationType: Configuration.self + for: providerId ) if let selectedEntity, filtersWithSelection { filters = VPNFilters(with: selectedEntity.server.provider)