Filter servers with category/country of selected server (#735)

And use Task for blocking actions in filters.
This commit is contained in:
Davide 2024-10-15 23:48:27 +02:00 committed by GitHub
parent aeaf0a6eed
commit 9656e5ed29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 36 additions and 33 deletions

View File

@ -41,7 +41,7 @@
"kind" : "remoteSourceControl",
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
"state" : {
"revision" : "c4182832032fab8fef24386d209572a2c288e28e"
"revision" : "5c402931e0628f3280c603cce5c8c3d05b1cfa1f"
}
},
{

View File

@ -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: "c4182832032fab8fef24386d209572a2c288e28e"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "5c402931e0628f3280c603cce5c8c3d05b1cfa1f"),
// .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"),

View File

@ -38,7 +38,7 @@ struct VPNFiltersModifier<Configuration>: ViewModifier where Configuration: Deco
contentView(with: content)
.onChange(of: manager.parameters.filters) { _ in
Task {
await manager.applyFilters()
manager.applyFilters()
}
}
}

View File

@ -34,9 +34,6 @@ struct VPNFiltersView<Configuration>: View where Configuration: Decodable {
@ObservedObject
var manager: VPNProviderManager
@State
private var isRefreshing = false
var body: some View {
Form {
Section {
@ -96,9 +93,11 @@ private extension VPNFiltersView {
var clearFiltersButton: some View {
Button("Clear filters", role: .destructive) {
Task {
manager.resetFilters()
}
}
}
}
private extension VPNFiltersView {

View File

@ -84,18 +84,22 @@ private extension VPNProviderContentModifier {
guard let providerId else {
return
}
let initialEntity = isInitial ? selectedEntity : nil
if !isInitial {
selectedEntity = nil
}
vpnProviderManager.view = manager.vpnView(
let view = manager.vpnView(
for: providerId,
configurationType: OpenVPN.Configuration.self,
initialParameters: .init(sorting: [
initialParameters: .init(
sorting: [
.localizedCountry,
.area,
.hostname
])
]
)
)
vpnProviderManager.setView(view, filteringWith: initialEntity?.server.provider)
}
func onSelectServer(server: VPNServer, preset: VPNPreset<Configuration>) {

View File

@ -31,16 +31,13 @@ import SwiftUI
extension VPNFiltersModifier {
func contentView(with content: Content) -> some View {
List {
content
}
.toolbar {
Button {
isFiltersPresented = true
} label: {
Image(systemName: "line.3.horizontal.decrease")
}
}
.themeModal(isPresented: $isFiltersPresented) {
NavigationStack {
VPNFiltersView<Configuration>(manager: manager)
@ -50,6 +47,7 @@ extension VPNFiltersModifier {
.presentationDetents([.medium])
}
}
}
}
#endif

View File

@ -33,12 +33,14 @@ extension VPNProviderServerView {
@ViewBuilder
var serversView: some View {
ForEach(manager.filteredServers) { server in
List {
ForEach(manager.filteredServers, id: \.id) { server in
Button("\(server.hostname ?? server.id) \(server.provider.countryCodes)") {
selectServer(server)
}
}
}
}
}
#endif