parent
8815e6fdf7
commit
91a3e42533
|
@ -143,7 +143,7 @@ private extension AppInlineCoordinator {
|
|||
func modalDestination(for item: ModalRoute?) -> some View {
|
||||
switch item {
|
||||
case .editProviderEntity(let profile, let module, let provider):
|
||||
ProviderSelectorView(
|
||||
ProviderEntitySelector(
|
||||
profileManager: profileManager,
|
||||
tunnel: tunnel,
|
||||
profile: profile,
|
||||
|
|
|
@ -135,7 +135,7 @@ extension AppModalCoordinator {
|
|||
}
|
||||
|
||||
case .editProviderEntity(let profile, let module, let provider):
|
||||
ProviderSelectorView(
|
||||
ProviderEntitySelector(
|
||||
profileManager: profileManager,
|
||||
tunnel: tunnel,
|
||||
profile: profile,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// ProviderSelectorView.swift
|
||||
// ProviderEntitySelector.swift
|
||||
// Passepartout
|
||||
//
|
||||
// Created by Davide De Rosa on 10/22/24.
|
||||
|
@ -27,7 +27,7 @@ import AppLibrary
|
|||
import PassepartoutKit
|
||||
import SwiftUI
|
||||
|
||||
struct ProviderSelectorView: View {
|
||||
struct ProviderEntitySelector: View {
|
||||
|
||||
@EnvironmentObject
|
||||
private var profileProcessor: ProfileProcessor
|
||||
|
@ -53,7 +53,7 @@ struct ProviderSelectorView: View {
|
|||
}
|
||||
}
|
||||
|
||||
private extension ProviderSelectorView {
|
||||
private extension ProviderEntitySelector {
|
||||
func onSelect(_ entity: any ProviderEntity & Encodable) async throws {
|
||||
pp_log(.app, .info, "Select new provider entity: \(entity)")
|
||||
|
|
@ -49,15 +49,8 @@ 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.data)
|
||||
}
|
||||
|
||||
return VPNProviderEntityCoordinator(
|
||||
VPNProviderServerCoordinator<OpenVPN.Configuration>(
|
||||
providerId: provider.id,
|
||||
selectedEntity: selectedEntity,
|
||||
onSelect: onSelect
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// VPNProviderEntityCoordinator.swift
|
||||
// VPNProviderServerCoordinator.swift
|
||||
// Passepartout
|
||||
//
|
||||
// Created by Davide De Rosa on 10/16/24.
|
||||
|
@ -27,15 +27,13 @@ import PassepartoutKit
|
|||
import SwiftUI
|
||||
import UtilsLibrary
|
||||
|
||||
struct VPNProviderEntityCoordinator<Configuration>: View where Configuration: ProviderConfigurationIdentifiable & Codable {
|
||||
struct VPNProviderServerCoordinator<Configuration>: View where Configuration: ProviderConfigurationIdentifiable & Codable {
|
||||
|
||||
@Environment(\.dismiss)
|
||||
private var dismiss
|
||||
|
||||
let providerId: ProviderID
|
||||
|
||||
let selectedEntity: VPNEntity<Configuration>?
|
||||
|
||||
let onSelect: (VPNEntity<Configuration>) async throws -> Void
|
||||
|
||||
@StateObject
|
||||
|
@ -44,10 +42,9 @@ struct VPNProviderEntityCoordinator<Configuration>: View where Configuration: Pr
|
|||
var body: some View {
|
||||
NavigationStack {
|
||||
VPNProviderServerView(
|
||||
apis: API.shared,
|
||||
providerId: providerId,
|
||||
configurationType: Configuration.self,
|
||||
selectedEntity: selectedEntity,
|
||||
selectedEntity: nil,
|
||||
onSelect: onSelect
|
||||
)
|
||||
.toolbar {
|
||||
|
@ -68,7 +65,7 @@ struct VPNProviderEntityCoordinator<Configuration>: View where Configuration: Pr
|
|||
}
|
||||
}
|
||||
|
||||
private extension VPNProviderEntityCoordinator {
|
||||
private extension VPNProviderServerCoordinator {
|
||||
func onSelect(server: VPNServer, preset: VPNPreset<Configuration>) {
|
||||
Task {
|
||||
do {
|
||||
|
@ -76,7 +73,7 @@ private extension VPNProviderEntityCoordinator {
|
|||
try await onSelect(entity)
|
||||
dismiss()
|
||||
} catch {
|
||||
pp_log(.app, .fault, "Unable to select server \(server.serverId): \(error)")
|
||||
pp_log(.app, .fault, "Unable to select server \(server.serverId) for provider \(server.provider.id): \(error)")
|
||||
errorHandler.handle(error, title: Strings.Global.servers)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue