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 {
|
var presetPicker: some View {
|
||||||
Picker(Strings.Views.Vpn.preset, selection: $model.filters.presetId) {
|
Picker(Strings.Views.Vpn.preset, selection: $model.filters.presetId) {
|
||||||
Text(Strings.Global.Nouns.any)
|
|
||||||
.tag(nil as String?)
|
|
||||||
ForEach(model.presets, id: \.presetId) {
|
ForEach(model.presets, id: \.presetId) {
|
||||||
Text($0.description)
|
Text($0.description)
|
||||||
.tag($0.presetId as String?)
|
.tag($0.presetId as String?)
|
||||||
|
|
|
@ -132,25 +132,29 @@ private extension VPNProviderServerView {
|
||||||
return servers
|
return servers
|
||||||
}
|
}
|
||||||
|
|
||||||
var initialFilters: VPNFilters? {
|
var initialFilters: VPNFilters {
|
||||||
guard let selectedEntity, filtersWithSelection else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var filters = VPNFilters()
|
var filters = VPNFilters()
|
||||||
filters.categoryName = selectedEntity.server.provider.categoryName
|
|
||||||
|
// 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)
|
#if os(macOS)
|
||||||
filters.countryCode = selectedEntity.server.provider.countryCode
|
filters.countryCode = selectedEntity.server.provider.countryCode
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
return filters
|
return filters
|
||||||
}
|
}
|
||||||
|
|
||||||
func compatiblePreset(with server: VPNServer) -> VPNPreset<Configuration>? {
|
func compatiblePreset(with server: VPNServer) -> VPNPreset<Configuration>? {
|
||||||
vpnManager
|
vpnManager
|
||||||
.presets
|
.presets
|
||||||
.filter { preset in
|
.filter {
|
||||||
filtersViewModel.presets.contains {
|
$0.presetId == filtersViewModel.filters.presetId
|
||||||
preset.presetId == $0.presetId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.first {
|
.first {
|
||||||
if let supportedIds = server.provider.supportedPresetIds {
|
if let supportedIds = server.provider.supportedPresetIds {
|
||||||
|
|
Loading…
Reference in New Issue