Better observe updates explicitly after init

This commit is contained in:
Davide De Rosa 2022-04-18 15:32:28 +02:00
parent 5cafd9794d
commit f5c87d43c2
3 changed files with 9 additions and 4 deletions

View File

@ -139,6 +139,9 @@ class AppContext {
self.isEligibleForOnDemandRules()
}
profileManager.observeUpdates()
vpnManager.observeUpdates()
// app
reviewer.eventCountBeforeRating = Constants.Rating.eventCount

View File

@ -78,8 +78,6 @@ public class VPNManager: ObservableObject, RateLimited {
isOnDemandRulesSupported = { true }
currentState = ObservableState()
observeStrategy()
observeProfileManager()
}
public func toggle() -> Bool {
@ -156,6 +154,11 @@ public class VPNManager: ObservableObject, RateLimited {
// MARK: Observation
extension VPNManager {
public func observeUpdates() {
observeStrategy()
observeProfileManager()
}
private func observeStrategy() {
strategy.observe(into: currentState)
}

View File

@ -85,7 +85,6 @@ public class ProfileManager: ObservableObject {
self.strategy = strategy
currentProfile = ObservableProfile()
observeUpdates()
}
}
@ -275,7 +274,7 @@ extension ProfileManager {
}
extension ProfileManager {
private func observeUpdates() {
public func observeUpdates() {
strategy.willUpdateProfiles()
.dropFirst()
.sink {