diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Managers/ProfileManager.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Managers/ProfileManager.swift index 5a85b4cb..11674aac 100644 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Managers/ProfileManager.swift +++ b/PassepartoutLibrary/Sources/PassepartoutCore/Managers/ProfileManager.swift @@ -32,6 +32,8 @@ public protocol ProfileManager { var activeProfileId: UUID? { get } var currentProfileId: UUID? { get set } + + var didUpdateProfiles: PassthroughSubject { get } var didUpdateActiveProfile: PassthroughSubject { get } diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Managers/ProviderManager.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Managers/ProviderManager.swift index f97f816e..d084c345 100644 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Managers/ProviderManager.swift +++ b/PassepartoutLibrary/Sources/PassepartoutCore/Managers/ProviderManager.swift @@ -27,6 +27,8 @@ import Foundation import Combine public protocol ProviderManager { + var didUpdateProviders: PassthroughSubject { get } + func allProviders() -> [ProviderMetadata] func provider(withName name: ProviderName) -> ProviderMetadata? diff --git a/PassepartoutLibrary/Sources/PassepartoutProfiles/Managers/DefaultProfileManager.swift b/PassepartoutLibrary/Sources/PassepartoutProfiles/Managers/DefaultProfileManager.swift index 40e887a7..7054368b 100644 --- a/PassepartoutLibrary/Sources/PassepartoutProfiles/Managers/DefaultProfileManager.swift +++ b/PassepartoutLibrary/Sources/PassepartoutProfiles/Managers/DefaultProfileManager.swift @@ -79,6 +79,8 @@ public class DefaultProfileManager: ProfileManagerWithCurrentProfile, Observable public let currentProfile: ObservableProfile + public let didUpdateProfiles = PassthroughSubject() + public let didUpdateActiveProfile = PassthroughSubject() public let didCreateProfile = PassthroughSubject() @@ -329,6 +331,8 @@ extension DefaultProfileManager { pp_log.info("\tActive profile was deleted") self.activeProfileId = nil } + + didUpdateProfiles.send() // IMPORTANT: defer task to avoid recursive saves // FIXME: Core Data, not sure about this workaround diff --git a/PassepartoutLibrary/Sources/PassepartoutProviders/Managers/DefaultProviderManager.swift b/PassepartoutLibrary/Sources/PassepartoutProviders/Managers/DefaultProviderManager.swift index 1dc12d82..9d054f6d 100644 --- a/PassepartoutLibrary/Sources/PassepartoutProviders/Managers/DefaultProviderManager.swift +++ b/PassepartoutLibrary/Sources/PassepartoutProviders/Managers/DefaultProviderManager.swift @@ -44,6 +44,8 @@ public class DefaultProviderManager: ProviderManager, ObservableObject, RateLimi private let serverRepository: ServerRepository + public let didUpdateProviders = PassthroughSubject() + public init(appBuild: Int, bundleServices: WebServices, webServices: WebServices, persistence: Persistence) { self.appBuild = appBuild self.bundleServices = bundleServices @@ -118,6 +120,8 @@ public class DefaultProviderManager: ProviderManager, ObservableObject, RateLimi .tryMap { index in self.saveLastAction(self.indexActionName) try self.providerRepository.mergeIndex(index) + + self.didUpdateProviders.send() }.eraseToAnyPublisher() } @@ -167,6 +171,8 @@ public class DefaultProviderManager: ProviderManager, ObservableObject, RateLimi vpnProtocol: vpnProtocol, lastUpdate: pub.lastModified ?? Date() ) + + self.didUpdateProviders.send() } catch { pp_log.error("Unable to persist \(providerName) infrastructure (\(vpnProtocol)): \(error)") } @@ -178,6 +184,8 @@ public class DefaultProviderManager: ProviderManager, ObservableObject, RateLimi public func reset() { persistence.truncate() + + didUpdateProviders.send() } // MARK: RateLimited