Skip to content

Commit

Permalink
Revert "Fix incorrect selection of VPN preset (#996)"
Browse files Browse the repository at this point in the history
This reverts commit c7bba03.
  • Loading branch information
keeshux committed Dec 12, 2024
1 parent 4fb457a commit 690f167
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Library/Sources/AppUIMain/Views/VPN/VPNFiltersView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand Down
24 changes: 10 additions & 14 deletions Library/Sources/AppUIMain/Views/VPN/VPNProviderServerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Configuration>? {
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 {
Expand Down

0 comments on commit 690f167

Please sign in to comment.