mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-01-18 14:39:09 +00:00
Regroup views/logic of VPNProviderServerView
This commit is contained in:
parent
2075f109f2
commit
88c53bed2e
@ -147,25 +147,6 @@ private extension VPNProviderServerView {
|
||||
return filters
|
||||
}
|
||||
|
||||
func compatiblePresets(with server: VPNServer) -> [VPNPreset<Configuration>] {
|
||||
vpnManager
|
||||
.presets
|
||||
.filter {
|
||||
if let selectedId = filtersViewModel.filters.presetId {
|
||||
return $0.presetId == selectedId
|
||||
}
|
||||
return true
|
||||
}
|
||||
.filter {
|
||||
if let supportedIds = server.provider.supportedPresetIds {
|
||||
return supportedIds.contains($0.presetId)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension VPNProviderServerView {
|
||||
func loadInitialServers() async {
|
||||
do {
|
||||
let repository = try preferencesManager.preferencesRepository(forProviderWithId: providerId)
|
||||
@ -200,6 +181,23 @@ private extension VPNProviderServerView {
|
||||
}
|
||||
}
|
||||
|
||||
func compatiblePresets(with server: VPNServer) -> [VPNPreset<Configuration>] {
|
||||
vpnManager
|
||||
.presets
|
||||
.filter {
|
||||
if let selectedId = filtersViewModel.filters.presetId {
|
||||
return $0.presetId == selectedId
|
||||
}
|
||||
return true
|
||||
}
|
||||
.filter {
|
||||
if let supportedIds = server.provider.supportedPresetIds {
|
||||
return supportedIds.contains($0.presetId)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func onNewFilters(_ filters: VPNFilters) {
|
||||
Task {
|
||||
await reloadServers(filters: filters)
|
||||
|
@ -98,30 +98,6 @@ private extension VPNProviderServerView.ContentView {
|
||||
}
|
||||
}
|
||||
|
||||
var emptyView: some View {
|
||||
Text(Strings.Views.Vpn.noServers)
|
||||
}
|
||||
}
|
||||
|
||||
private extension VPNProviderServerView.ContentView {
|
||||
var countryCodes: [String] {
|
||||
filtersViewModel
|
||||
.countries
|
||||
.map(\.code)
|
||||
}
|
||||
|
||||
func isExpandedCountry(_ code: String) -> Binding<Bool> {
|
||||
Binding {
|
||||
expandedCodes.contains(code)
|
||||
} set: {
|
||||
if $0 {
|
||||
expandedCodes.insert(code)
|
||||
} else {
|
||||
expandedCodes.remove(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func countryView(for code: String) -> some View {
|
||||
serversByCountryCode[code]
|
||||
.map { servers in
|
||||
@ -159,6 +135,30 @@ private extension VPNProviderServerView.ContentView {
|
||||
}
|
||||
}
|
||||
|
||||
var emptyView: some View {
|
||||
Text(Strings.Views.Vpn.noServers)
|
||||
}
|
||||
}
|
||||
|
||||
private extension VPNProviderServerView.ContentView {
|
||||
var countryCodes: [String] {
|
||||
filtersViewModel
|
||||
.countries
|
||||
.map(\.code)
|
||||
}
|
||||
|
||||
func isExpandedCountry(_ code: String) -> Binding<Bool> {
|
||||
Binding {
|
||||
expandedCodes.contains(code)
|
||||
} set: {
|
||||
if $0 {
|
||||
expandedCodes.insert(code)
|
||||
} else {
|
||||
expandedCodes.remove(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func computeServersByCountry(_ servers: [VPNServer]) {
|
||||
var map: [String: [VPNServer]] = [:]
|
||||
servers.forEach {
|
||||
|
Loading…
Reference in New Issue
Block a user