Set supported preset on start

This commit is contained in:
Davide De Rosa 2019-05-04 10:28:54 +02:00
parent 6f1fe36412
commit d44e9f861b
2 changed files with 13 additions and 0 deletions

View File

@ -275,6 +275,9 @@ public class ConnectionService: Codable {
providerProfile.poolId = fallbackPool.id
}
// XXX: fix unsupported preset
providerProfile.setSupportedPreset()
profile = providerProfile
case .host:

View File

@ -76,6 +76,16 @@ public class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
presetId = infrastructure.defaults.preset
}
public func setSupportedPreset() {
guard let pool = pool else {
return
}
let supported = pool.supportedPresetIds(in: infrastructure)
if let current = preset?.id, !supported.contains(current), let fallback = supported.first {
presetId = fallback
}
}
private func validateEndpoint() {
guard let pool = pool, let preset = preset else {
manualAddress = nil