Filter servers with category/country of selected server (#735)
And use Task for blocking actions in filters.
This commit is contained in:
parent
aeaf0a6eed
commit
9656e5ed29
|
@ -41,7 +41,7 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
|
||||
"state" : {
|
||||
"revision" : "c4182832032fab8fef24386d209572a2c288e28e"
|
||||
"revision" : "5c402931e0628f3280c603cce5c8c3d05b1cfa1f"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,7 +93,9 @@ private extension VPNFiltersView {
|
|||
|
||||
var clearFiltersButton: some View {
|
||||
Button("Clear filters", role: .destructive) {
|
||||
manager.resetFilters()
|
||||
Task {
|
||||
manager.resetFilters()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: [
|
||||
.localizedCountry,
|
||||
.area,
|
||||
.hostname
|
||||
])
|
||||
initialParameters: .init(
|
||||
sorting: [
|
||||
.localizedCountry,
|
||||
.area,
|
||||
.hostname
|
||||
]
|
||||
)
|
||||
)
|
||||
vpnProviderManager.setView(view, filteringWith: initialEntity?.server.provider)
|
||||
}
|
||||
|
||||
func onSelectServer(server: VPNServer, preset: VPNPreset<Configuration>) {
|
||||
|
|
|
@ -31,24 +31,22 @@ import SwiftUI
|
|||
|
||||
extension VPNFiltersModifier {
|
||||
func contentView(with content: Content) -> some View {
|
||||
List {
|
||||
content
|
||||
}
|
||||
.toolbar {
|
||||
Button {
|
||||
isFiltersPresented = true
|
||||
} label: {
|
||||
Image(systemName: "line.3.horizontal.decrease")
|
||||
content
|
||||
.toolbar {
|
||||
Button {
|
||||
isFiltersPresented = true
|
||||
} label: {
|
||||
Image(systemName: "line.3.horizontal.decrease")
|
||||
}
|
||||
.themeModal(isPresented: $isFiltersPresented) {
|
||||
NavigationStack {
|
||||
VPNFiltersView<Configuration>(manager: manager)
|
||||
.navigationTitle("Filters")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
.presentationDetents([.medium])
|
||||
}
|
||||
}
|
||||
}
|
||||
.themeModal(isPresented: $isFiltersPresented) {
|
||||
NavigationStack {
|
||||
VPNFiltersView<Configuration>(manager: manager)
|
||||
.navigationTitle("Filters")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
.presentationDetents([.medium])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,11 @@ extension VPNProviderServerView {
|
|||
|
||||
@ViewBuilder
|
||||
var serversView: some View {
|
||||
ForEach(manager.filteredServers) { server in
|
||||
Button("\(server.hostname ?? server.id) \(server.provider.countryCodes)") {
|
||||
selectServer(server)
|
||||
List {
|
||||
ForEach(manager.filteredServers, id: \.id) { server in
|
||||
Button("\(server.hostname ?? server.id) \(server.provider.countryCodes)") {
|
||||
selectServer(server)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue