Multi-configuration providers (#756)
This commit is contained in:
parent
bbcd245bad
commit
2c2b3f063a
|
@ -41,7 +41,7 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
|
||||
"state" : {
|
||||
"revision" : "4fffdbde18ddaa5ab0fdfa9ee417a0f5015f59c6"
|
||||
"revision" : "7b3f68b30d2c3ac434c5aaa10853bd3709c5c308"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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<EntityType.Configuration>
|
||||
|
||||
return VPNProviderServerCoordinator(
|
||||
providerId: provider.id,
|
||||
selectedEntity: selectedEntity,
|
||||
onSelect: onSelect
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,16 +49,6 @@ extension OpenVPNModule: ProviderEntityViewProviding {
|
|||
with provider: ModuleMetadata.Provider,
|
||||
onSelect: @escaping (any ProviderEntity & Encodable) async throws -> Void
|
||||
) -> some View {
|
||||
let selectedEntity: VPNEntity<OpenVPN.Configuration>? = try? provider
|
||||
.entity
|
||||
.map {
|
||||
try providerEntity(from: $0)
|
||||
}
|
||||
|
||||
return VPNProviderServerCoordinator(
|
||||
providerId: provider.id,
|
||||
selectedEntity: selectedEntity,
|
||||
onSelect: onSelect
|
||||
)
|
||||
vpnProviderEntityView(with: provider, onSelect: onSelect)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)")
|
||||
|
|
|
@ -73,8 +73,7 @@ struct VPNProviderServerView<Configuration>: 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)
|
||||
|
|
Loading…
Reference in New Issue