diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index aec74ce602..029c8cce1d 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -1321,6 +1321,7 @@ 6AC6DAB228804F97002723C0 /* BarsAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarsAnimator.swift; sourceTree = ""; }; 6AC98418288055C1005FA9CA /* BarsAnimatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarsAnimatorTests.swift; sourceTree = ""; }; 6FB030C7234331B400A10DB9 /* Configuration.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Configuration.xcconfig; path = Configuration/Configuration.xcconfig; sourceTree = ""; }; + 7BD952552B061D5E00BCCB7A /* BrowserServicesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserServicesKit; path = ../../BrowserServicesKit; sourceTree = ""; }; 83004E7F2193BB8200DA013C /* WKNavigationExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKNavigationExtension.swift; sourceTree = ""; }; 83004E832193E14C00DA013C /* UIAlertControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = UIAlertControllerExtension.swift; path = ../Core/UIAlertControllerExtension.swift; sourceTree = ""; }; 83004E852193E5ED00DA013C /* TabViewControllerBrowsingMenuExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabViewControllerBrowsingMenuExtension.swift; sourceTree = ""; }; @@ -3342,6 +3343,7 @@ 31E69A60280F4BAD00478327 /* LocalPackages */ = { isa = PBXGroup; children = ( + 7BD952552B061D5E00BCCB7A /* BrowserServicesKit */, 85875B5F29912A2D00115F05 /* SyncUI */, 37FCAACB2993149A000E420A /* Waitlist */, 31794BFF2821DFB600F18633 /* DuckUI */, @@ -9131,7 +9133,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = revision; - revision = d1784c9240204ece3349e8cd65b621876653c4d0; + revision = 299e73ed6c9dc83f2b3935c4ba5d230cbb4e5489; }; }; C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index dc385ee3f8..b440d27622 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -10,15 +10,6 @@ "version": "3.0.0" } }, - { - "package": "BrowserServicesKit", - "repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit", - "state": { - "branch": null, - "revision": "d1784c9240204ece3349e8cd65b621876653c4d0", - "version": null - } - }, { "package": "CocoaAsyncSocket", "repositoryURL": "https://github.com/robbiehanson/CocoaAsyncSocket", diff --git a/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift b/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift index 8cddce00d9..985c9a0efa 100644 --- a/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift +++ b/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift @@ -54,9 +54,9 @@ extension NetworkProtectionKeychainTokenStore { extension NetworkProtectionCodeRedemptionCoordinator { convenience init() { - let tunnelSettings = TunnelSettings(defaults: .networkProtectionGroupDefaults) + let settings = VPNSettings(defaults: .networkProtectionGroupDefaults) self.init( - environment: tunnelSettings.selectedEnvironment, + environment: settings.selectedEnvironment, tokenStore: NetworkProtectionKeychainTokenStore(), errorEvents: .networkProtectionAppDebugEvents ) @@ -65,32 +65,30 @@ extension NetworkProtectionCodeRedemptionCoordinator { extension NetworkProtectionVPNNotificationsViewModel { convenience init() { - let notificationsSettingsStore = NetworkProtectionNotificationsSettingsUserDefaultsStore(userDefaults: .networkProtectionGroupDefaults) self.init( notificationsAuthorization: NotificationsAuthorizationController(), - notificationsSettingsStore: notificationsSettingsStore - ) + settings: VPNSettings(defaults: .networkProtectionGroupDefaults)) } } extension NetworkProtectionVPNSettingsViewModel { convenience init() { self.init( - tunnelSettings: TunnelSettings(defaults: .networkProtectionGroupDefaults) + settings: VPNSettings(defaults: .networkProtectionGroupDefaults) ) } } extension NetworkProtectionVPNLocationViewModel { convenience init() { - let tunnelSettings = TunnelSettings(defaults: .networkProtectionGroupDefaults) + let settings = VPNSettings(defaults: .networkProtectionGroupDefaults) let locationListRepository = NetworkProtectionLocationListCompositeRepository( - environment: tunnelSettings.selectedEnvironment, + environment: settings.selectedEnvironment, tokenStore: NetworkProtectionKeychainTokenStore() ) self.init( locationListRepository: locationListRepository, - tunnelSettings: TunnelSettings(defaults: .networkProtectionGroupDefaults) + settings: VPNSettings(defaults: .networkProtectionGroupDefaults) ) } } diff --git a/DuckDuckGo/NetworkProtectionVPNLocationView.swift b/DuckDuckGo/NetworkProtectionVPNLocationView.swift index b9d2a337fd..6381d55401 100644 --- a/DuckDuckGo/NetworkProtectionVPNLocationView.swift +++ b/DuckDuckGo/NetworkProtectionVPNLocationView.swift @@ -58,12 +58,12 @@ import NetworkProtection final class NetworkProtectionVPNLocationViewModel: ObservableObject { private let locationListRepository: NetworkProtectionLocationListRepository - private let tunnelSettings: TunnelSettings + private let settings: VPNSettings @Published public var countryItems: [NetworkProtectionVPNCountryItemModel] = [] - init(locationListRepository: NetworkProtectionLocationListRepository, tunnelSettings: TunnelSettings) { + init(locationListRepository: NetworkProtectionLocationListRepository, settings: VPNSettings) { self.locationListRepository = locationListRepository - self.tunnelSettings = tunnelSettings + self.settings = settings } @MainActor @@ -73,12 +73,12 @@ final class NetworkProtectionVPNLocationViewModel: ObservableObject { } func onNearestItemSelection() { - tunnelSettings.selectedLocation = .nearest + settings.selectedLocation = .nearest } func onCountryItemSelection(countryID: String) { let location = NetworkProtectionSelectedLocation(country: countryID) - tunnelSettings.selectedLocation = .location(location) + settings.selectedLocation = .location(location) } } diff --git a/DuckDuckGo/NetworkProtectionVPNNotificationsViewModel.swift b/DuckDuckGo/NetworkProtectionVPNNotificationsViewModel.swift index 62833eb25a..096f2194c9 100644 --- a/DuckDuckGo/NetworkProtectionVPNNotificationsViewModel.swift +++ b/DuckDuckGo/NetworkProtectionVPNNotificationsViewModel.swift @@ -31,16 +31,16 @@ enum NetworkProtectionNotificationsViewKind: Equatable { final class NetworkProtectionVPNNotificationsViewModel: ObservableObject { private var notificationsAuthorization: NotificationsAuthorizationControlling - private var notificationsSettingsStore: NetworkProtectionNotificationsSettingsStore + private var settings: VPNSettings @Published var viewKind: NetworkProtectionNotificationsViewKind = .loading var alertsEnabled: Bool { - self.notificationsSettingsStore.alertsEnabled + self.settings.notifyStatusChanges } init(notificationsAuthorization: NotificationsAuthorizationControlling, - notificationsSettingsStore: NetworkProtectionNotificationsSettingsStore) { + settings: VPNSettings) { self.notificationsAuthorization = notificationsAuthorization - self.notificationsSettingsStore = notificationsSettingsStore + self.settings = settings self.notificationsAuthorization.delegate = self } @@ -55,7 +55,7 @@ final class NetworkProtectionVPNNotificationsViewModel: ObservableObject { } func didToggleAlerts(to enabled: Bool) { - notificationsSettingsStore.alertsEnabled = enabled + settings.notifyStatusChanges = enabled } private func updateViewKind(for authorizationStatus: UNAuthorizationStatus) { diff --git a/DuckDuckGo/NetworkProtectionVPNSettingsViewModel.swift b/DuckDuckGo/NetworkProtectionVPNSettingsViewModel.swift index 19664143e8..14820ce112 100644 --- a/DuckDuckGo/NetworkProtectionVPNSettingsViewModel.swift +++ b/DuckDuckGo/NetworkProtectionVPNSettingsViewModel.swift @@ -24,14 +24,14 @@ import NetworkProtection import Combine final class NetworkProtectionVPNSettingsViewModel: ObservableObject { - private let tunnelSettings: TunnelSettings + private let settings: VPNSettings private var cancellable: AnyCancellable? @Published public var preferredLocation: String = UserText.netPPreferredLocationNearest - init(tunnelSettings: TunnelSettings) { - self.tunnelSettings = tunnelSettings - cancellable = tunnelSettings.selectedLocationPublisher.map { selectedLocation in + init(settings: VPNSettings) { + self.settings = settings + cancellable = settings.selectedLocationPublisher.map { selectedLocation in guard let selectedLocation = selectedLocation.location else { return UserText.netPPreferredLocationNearest } diff --git a/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift b/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift index 4943d79eb3..0f1fe33c1b 100644 --- a/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift +++ b/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift @@ -176,9 +176,9 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider { errorEvents: nil) let errorStore = NetworkProtectionTunnelErrorStore() let notificationsPresenter = NetworkProtectionUNNotificationPresenter() - let notificationsSettingsStore = NetworkProtectionNotificationsSettingsUserDefaultsStore(userDefaults: .networkProtectionGroupDefaults) + let settings = VPNSettings(defaults: .networkProtectionGroupDefaults) let nofificationsPresenterDecorator = NetworkProtectionNotificationsPresenterTogglableDecorator( - notificationSettingsStore: notificationsSettingsStore, + settings: settings, wrappee: notificationsPresenter ) notificationsPresenter.requestAuthorization() @@ -189,7 +189,7 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider { tokenStore: tokenStore, debugEvents: Self.networkProtectionDebugEvents(controllerErrorStore: errorStore), providerEvents: Self.packetTunnelProviderEvents, - tunnelSettings: TunnelSettings(defaults: .networkProtectionGroupDefaults)) + settings: settings) startMonitoringMemoryPressureEvents() observeServerChanges() APIRequest.Headers.setUserAgent(DefaultUserAgentManager.duckDuckGoUserAgent)