From 690f167b98bdd956897c554673a52d967ad74f99 Mon Sep 17 00:00:00 2001 From: Davide Date: Thu, 12 Dec 2024 17:31:13 +0100 Subject: [PATCH] Revert "Fix incorrect selection of VPN preset (#996)" This reverts commit c7bba033fea68fe10d685a57199c7967088eb91a. --- .../AppUIMain/Views/VPN/VPNFiltersView.swift | 2 ++ .../Views/VPN/VPNProviderServerView.swift | 24 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) 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 {