diff --git a/Library/Sources/AppUIMain/Views/VPN/VPNFiltersView.swift b/Library/Sources/AppUIMain/Views/VPN/VPNFiltersView.swift index 66e42a6fc..bb018a728 100644 --- a/Library/Sources/AppUIMain/Views/VPN/VPNFiltersView.swift +++ b/Library/Sources/AppUIMain/Views/VPN/VPNFiltersView.swift @@ -93,6 +93,8 @@ private extension VPNFiltersView { var presetPicker: some View { Picker(Strings.Views.Vpn.preset, selection: $model.filters.presetId) { + Text(Strings.Global.Nouns.any) + .tag(nil as String?) ForEach(model.presets, id: \.presetId) { Text($0.description) .tag($0.presetId as String?) diff --git a/Library/Sources/AppUIMain/Views/VPN/VPNProviderServerView.swift b/Library/Sources/AppUIMain/Views/VPN/VPNProviderServerView.swift index 0508add16..1354e38f9 100644 --- a/Library/Sources/AppUIMain/Views/VPN/VPNProviderServerView.swift +++ b/Library/Sources/AppUIMain/Views/VPN/VPNProviderServerView.swift @@ -132,29 +132,25 @@ private extension VPNProviderServerView { return servers } - var initialFilters: VPNFilters { + var initialFilters: VPNFilters? { + guard let selectedEntity, filtersWithSelection else { + return nil + } var filters = VPNFilters() - - // force initial preset filter - filters.presetId = vpnManager.options.presets.first?.presetId - - if let selectedEntity { - filters.presetId = selectedEntity.preset.presetId - if filtersWithSelection { - filters.categoryName = selectedEntity.server.provider.categoryName + filters.categoryName = selectedEntity.server.provider.categoryName #if os(macOS) - filters.countryCode = selectedEntity.server.provider.countryCode + filters.countryCode = selectedEntity.server.provider.countryCode #endif - } - } return filters } func compatiblePreset(with server: VPNServer) -> VPNPreset? { vpnManager .presets - .filter { - $0.presetId == filtersViewModel.filters.presetId + .filter { preset in + filtersViewModel.presets.contains { + preset.presetId == $0.presetId + } } .first { if let supportedIds = server.provider.supportedPresetIds {