From d60ab979222023ead41839b9da2354d39d2b5a2c Mon Sep 17 00:00:00 2001 From: Davide Date: Tue, 29 Oct 2024 00:15:56 +0100 Subject: [PATCH] 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 --- .../AppUI/Views/Provider/VPNFiltersView.swift | 14 ++++++++++---- .../Views/Provider/VPNProviderServerView.swift | 7 ++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Passepartout/Library/Sources/AppUI/Views/Provider/VPNFiltersView.swift b/Passepartout/Library/Sources/AppUI/Views/Provider/VPNFiltersView.swift index 2c0a1567..aab44d2a 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Provider/VPNFiltersView.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Provider/VPNFiltersView.swift @@ -52,15 +52,21 @@ struct VPNFiltersView: View { #endif } } - .onChange(of: model.filters.categoryName) { _ in - model.filters.countryCode = nil - } } } private extension VPNFiltersView { + var categoryNameBinding: Binding { + Binding { + model.filters.categoryName + } set: { + model.filters.categoryName = $0 + model.filters.countryCode = nil + } + } + var categoryPicker: some View { - Picker(Strings.Global.category, selection: $model.filters.categoryName) { + Picker(Strings.Global.category, selection: categoryNameBinding) { Text(Strings.Global.any) .tag(nil as String?) ForEach(model.categories, id: \.self) { diff --git a/Passepartout/Library/Sources/AppUI/Views/Provider/VPNProviderServerView.swift b/Passepartout/Library/Sources/AppUI/Views/Provider/VPNProviderServerView.swift index 3bfe3197..48aedd52 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Provider/VPNProviderServerView.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Provider/VPNProviderServerView.swift @@ -81,7 +81,12 @@ extension VPNProviderServerView { guard let selectedEntity, filtersWithSelection else { 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, onSelect: onSelect,