Fix incorrect selection of VPN preset (#996)
Drop "Any" to rather make the preset filter an explicit preset selection. Regardless of `filtersWithSelection`, _always_ enforce the preset filter to: - The preset of the currently selected entity - The first among available presets (normally non-empty) Fixes #995
This commit is contained in:
parent
6f9c78b257
commit
c7bba033fe
|
@ -93,8 +93,6 @@ 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?)
|
||||
|
|
|
@ -132,25 +132,29 @@ private extension VPNProviderServerView {
|
|||
return servers
|
||||
}
|
||||
|
||||
var initialFilters: VPNFilters? {
|
||||
guard let selectedEntity, filtersWithSelection else {
|
||||
return nil
|
||||
}
|
||||
var initialFilters: VPNFilters {
|
||||
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
|
||||
#if os(macOS)
|
||||
filters.countryCode = selectedEntity.server.provider.countryCode
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return filters
|
||||
}
|
||||
|
||||
func compatiblePreset(with server: VPNServer) -> VPNPreset<Configuration>? {
|
||||
vpnManager
|
||||
.presets
|
||||
.filter { preset in
|
||||
filtersViewModel.presets.contains {
|
||||
preset.presetId == $0.presetId
|
||||
}
|
||||
.filter {
|
||||
$0.presetId == filtersViewModel.filters.presetId
|
||||
}
|
||||
.first {
|
||||
if let supportedIds = server.provider.supportedPresetIds {
|
||||
|
|
Loading…
Reference in New Issue