Optionally apply filters based on server selection (#754)
Restore passing selectedEntity, but add filtersWithSelection to decide
whether to filter servers based on selection.
Partially revert 91a3e42533
This commit is contained in:
parent
1e06c350ee
commit
1a82aea612
|
@ -41,7 +41,7 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
|
||||
"state" : {
|
||||
"revision" : "079fb0e57cecfc2ed128ae9bf8614fcf3c2a6582"
|
||||
"revision" : "a0cb540f739c58d04756d15b9a7bb21fae52c95f"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -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: "079fb0e57cecfc2ed128ae9bf8614fcf3c2a6582"),
|
||||
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "a0cb540f739c58d04756d15b9a7bb21fae52c95f"),
|
||||
// .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"),
|
||||
|
|
|
@ -49,8 +49,15 @@ extension OpenVPNModule: ProviderEntityViewProviding {
|
|||
with provider: ModuleMetadata.Provider,
|
||||
onSelect: @escaping (any ProviderEntity & Encodable) async throws -> Void
|
||||
) -> some View {
|
||||
VPNProviderServerCoordinator<OpenVPN.Configuration>(
|
||||
let selectedEntity: VPNEntity<OpenVPN.Configuration>? = try? provider
|
||||
.entity
|
||||
.map {
|
||||
try providerEntity(from: $0)
|
||||
}
|
||||
|
||||
return VPNProviderServerCoordinator(
|
||||
providerId: provider.id,
|
||||
selectedEntity: selectedEntity,
|
||||
onSelect: onSelect
|
||||
)
|
||||
}
|
||||
|
|
|
@ -131,6 +131,7 @@ private extension OpenVPNView {
|
|||
providerId: $0,
|
||||
configurationType: OpenVPN.Configuration.self,
|
||||
selectedEntity: providerEntity.wrappedValue,
|
||||
filtersWithSelection: true,
|
||||
onSelect: onSelectServer
|
||||
)
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ struct VPNProviderServerCoordinator<Configuration>: View where Configuration: Pr
|
|||
|
||||
let providerId: ProviderID
|
||||
|
||||
let selectedEntity: VPNEntity<Configuration>?
|
||||
|
||||
let onSelect: (VPNEntity<Configuration>) async throws -> Void
|
||||
|
||||
@StateObject
|
||||
|
@ -44,7 +46,8 @@ struct VPNProviderServerCoordinator<Configuration>: View where Configuration: Pr
|
|||
VPNProviderServerView(
|
||||
providerId: providerId,
|
||||
configurationType: Configuration.self,
|
||||
selectedEntity: nil,
|
||||
selectedEntity: selectedEntity,
|
||||
filtersWithSelection: false,
|
||||
onSelect: onSelect
|
||||
)
|
||||
.toolbar {
|
||||
|
|
|
@ -41,6 +41,8 @@ struct VPNProviderServerView<Configuration>: View where Configuration: ProviderC
|
|||
|
||||
let selectedEntity: VPNEntity<Configuration>?
|
||||
|
||||
let filtersWithSelection: Bool
|
||||
|
||||
let onSelect: (_ server: VPNServer, _ preset: VPNPreset<Configuration>) -> Void
|
||||
|
||||
@StateObject
|
||||
|
@ -74,7 +76,7 @@ struct VPNProviderServerView<Configuration>: View where Configuration: ProviderC
|
|||
for: providerId,
|
||||
configurationType: Configuration.self
|
||||
)
|
||||
if let selectedEntity {
|
||||
if let selectedEntity, filtersWithSelection {
|
||||
filters = VPNFilters(with: selectedEntity.server.provider)
|
||||
} else {
|
||||
filters = VPNFilters()
|
||||
|
@ -122,6 +124,7 @@ extension VPNProviderServerView {
|
|||
providerId: .protonvpn,
|
||||
configurationType: OpenVPN.Configuration.self,
|
||||
selectedEntity: nil,
|
||||
filtersWithSelection: false,
|
||||
onSelect: { _, _ in }
|
||||
)
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ private extension VPNProviderServerView.Subview {
|
|||
ThemeImage(.marked)
|
||||
.opacity(server.id == selectedServer?.id ? 1.0 : 0.0)
|
||||
}
|
||||
.width(max: 20.0)
|
||||
.width(10.0)
|
||||
|
||||
TableColumn(Strings.Global.region) { server in
|
||||
HStack {
|
||||
|
@ -65,7 +65,6 @@ private extension VPNProviderServerView.Subview {
|
|||
Text(server.region)
|
||||
}
|
||||
}
|
||||
.width(max: 200.0)
|
||||
|
||||
TableColumn(Strings.Global.address, value: \.address)
|
||||
|
||||
|
@ -76,7 +75,6 @@ private extension VPNProviderServerView.Subview {
|
|||
Text(Strings.Views.Provider.selectServer)
|
||||
}
|
||||
}
|
||||
.width(min: 100.0, max: 100.0)
|
||||
}
|
||||
.disabled(manager.isFiltering)
|
||||
}
|
||||
|
@ -99,6 +97,7 @@ private extension VPNProviderServerView.Subview {
|
|||
providerId: .tunnelbear,
|
||||
configurationType: OpenVPN.Configuration.self,
|
||||
selectedEntity: nil,
|
||||
filtersWithSelection: false,
|
||||
onSelect: { _, _ in }
|
||||
)
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ private struct ProviderCountryFlag: View {
|
|||
|
||||
var body: some View {
|
||||
ThemeCountryFlag(
|
||||
code: provider.entity?.countryCode,
|
||||
code: provider.entity?.header.countryCode,
|
||||
placeholderTip: Strings.Errors.App.Provider.missingEntity,
|
||||
countryTip: {
|
||||
$0.localizedAsRegionCode
|
||||
|
|
Loading…
Reference in New Issue