Delegate profile updates internally

This commit is contained in:
Davide De Rosa 2021-01-08 18:46:57 +01:00
parent 170d089a44
commit 8313cc9497
3 changed files with 5 additions and 10 deletions

View File

@ -430,7 +430,7 @@ class StatusMenu: NSObject {
return
}
assert(!group.pools.isEmpty)
service.setPoolId(group.pools.randomElement()!.id, forProviderProfile: profile)
profile.poolId = group.pools.randomElement()!.id
vpn.reconnect(completionHandler: nil)
// update menu
@ -447,7 +447,7 @@ class StatusMenu: NSObject {
guard let profile = service.activeProfile as? ProviderConnectionProfile else {
return
}
service.setPoolId(pool.id, forProviderProfile: profile)
profile.poolId = pool.id
vpn.reconnect(completionHandler: nil)
// update menu

View File

@ -338,7 +338,7 @@ extension ServiceViewController: ProviderServiceViewDelegate {
uncheckedProviderProfile.presetId = fallback
}
service.setPoolId(pool.id, forProviderProfile: uncheckedProviderProfile)
uncheckedProviderProfile.poolId = pool.id
// vpn.reinstallIfEnabled()
}

View File

@ -63,6 +63,7 @@ public class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
public var poolId: String {
didSet {
validateEndpoint()
serviceDelegate?.connectionService(didUpdate: self)
}
}
@ -73,6 +74,7 @@ public class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
public var presetId: String {
didSet {
validateEndpoint()
serviceDelegate?.connectionService(didUpdate: self)
}
}
@ -240,10 +242,3 @@ public extension ProviderConnectionProfile {
return true
}
}
public extension ConnectionService {
func setPoolId(_ poolId: String, forProviderProfile profile: ProviderConnectionProfile) {
profile.poolId = poolId
delegate?.connectionService(didUpdate: profile)
}
}