Fix initial country filters (#771)

- iOS: skip filter to speed up selection of another country
- macOS: initial country filter was lost due to category/country
chaining
This commit is contained in:
Davide 2024-10-29 00:15:56 +01:00 committed by GitHub
parent 92cf1985e2
commit d60ab97922
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 5 deletions

View File

@ -52,15 +52,21 @@ struct VPNFiltersView: View {
#endif #endif
} }
} }
.onChange(of: model.filters.categoryName) { _ in
model.filters.countryCode = nil
}
} }
} }
private extension VPNFiltersView { private extension VPNFiltersView {
var categoryNameBinding: Binding<String?> {
Binding {
model.filters.categoryName
} set: {
model.filters.categoryName = $0
model.filters.countryCode = nil
}
}
var categoryPicker: some View { var categoryPicker: some View {
Picker(Strings.Global.category, selection: $model.filters.categoryName) { Picker(Strings.Global.category, selection: categoryNameBinding) {
Text(Strings.Global.any) Text(Strings.Global.any)
.tag(nil as String?) .tag(nil as String?)
ForEach(model.categories, id: \.self) { ForEach(model.categories, id: \.self) {

View File

@ -81,7 +81,12 @@ extension VPNProviderServerView {
guard let selectedEntity, filtersWithSelection else { guard let selectedEntity, filtersWithSelection else {
return nil return nil
} }
return VPNFilters(with: selectedEntity.server.provider) var filters = VPNFilters()
filters.categoryName = selectedEntity.server.provider.categoryName
#if os(macOS)
filters.countryCode = selectedEntity.server.provider.countryCode
#endif
return filters
}(), }(),
selectTitle: selectTitle, selectTitle: selectTitle,
onSelect: onSelect, onSelect: onSelect,