From b835c0a430db700e893e3900314a37c413fb107c Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Tue, 12 Sep 2023 19:11:03 +0200 Subject: [PATCH] Fixes startup options reset (#1581) Task/Issue URL: https://app.asana.com/0/0/1205465612515839/f BSK PR: https://github.com/duckduckgo/BrowserServicesKit/pull/489 iOS PR: https://github.com/duckduckgo/iOS/pull/2003 ## Description Fixes startup options reset, and improves the options loading logic so we can easily unit test it. --- DuckDuckGo.xcodeproj/project.pbxproj | 3 +-- .../BothAppTargets/NetworkProtectionOnboardingMenu.swift | 2 +- .../NetworkProtectionTunnelController.swift | 8 ++++---- LocalPackages/DataBrokerProtection/Package.swift | 2 +- LocalPackages/NetworkProtectionUI/Package.swift | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index c79348276b..e286d1feef 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -9470,7 +9470,6 @@ 3706FAC4293F65D500E42796 /* PrintingUserScript.swift in Sources */, 9D9AE86C2AA76D1B0026E7DC /* LoginItemsManager.swift in Sources */, 4B9DB0392A983B24000927DB /* JoinedWaitlistView.swift in Sources */, - 4B4D60B42A0C847900BCD287 /* LoginItem.swift in Sources */, 3706FEBF293F6EFF00E42796 /* BWError.swift in Sources */, 3706FAC6293F65D500E42796 /* ConnectBitwardenViewController.swift in Sources */, EEC589DA2A4F1CE400BCD60C /* AppLauncher.swift in Sources */, @@ -12278,7 +12277,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 77.3.0; + version = 77.3.1; }; }; AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = { diff --git a/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionOnboardingMenu.swift b/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionOnboardingMenu.swift index aecd17470c..f1a7dbbfcb 100644 --- a/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionOnboardingMenu.swift +++ b/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionOnboardingMenu.swift @@ -30,7 +30,7 @@ final class NetworkProtectionOnboardingMenu: NSMenu { import NetworkProtection import NetworkProtectionUI -/// Implements the logic for Network Protection's simulate failures menu. +/// Implements the logic for Network Protection's onboarding menu. /// @objc @MainActor diff --git a/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionTunnelController.swift b/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionTunnelController.swift index a3ea541930..b02febcb87 100644 --- a/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionTunnelController.swift +++ b/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionTunnelController.swift @@ -159,8 +159,7 @@ final class NetworkProtectionTunnelController: NetworkProtection.TunnelControlle protocolConfiguration.providerConfiguration = [ NetworkProtectionOptionKey.defaultPixelHeaders: APIRequest.Headers().httpHeaders, NetworkProtectionOptionKey.excludedRoutes: excludedRoutes().map(\.stringRepresentation) as NSArray, - NetworkProtectionOptionKey.includedRoutes: includedRoutes().map(\.stringRepresentation) as NSArray, - NetworkProtectionOptionKey.connectionTesterEnabled: NSNumber(value: isConnectionTesterEnabled) + NetworkProtectionOptionKey.includedRoutes: includedRoutes().map(\.stringRepresentation) as NSArray ] // always-on @@ -315,15 +314,16 @@ final class NetworkProtectionTunnelController: NetworkProtection.TunnelControlle options[NetworkProtectionOptionKey.authToken] = try tokenStore.fetchToken() as NSString? options[NetworkProtectionOptionKey.selectedServer] = debugUtilities.selectedServerName() as NSString? options[NetworkProtectionOptionKey.keyValidity] = debugUtilities.registrationKeyValidity.map(String.init(describing:)) as NSString? + options[NetworkProtectionOptionKey.connectionTesterEnabled] = await NSNumber(value: isConnectionTesterEnabled) if Self.simulationOptions.isEnabled(.tunnelFailure) { Self.simulationOptions.setEnabled(false, option: .tunnelFailure) - options[NetworkProtectionOptionKey.tunnelFailureSimulation] = NetworkProtectionOptionValue.true + options[NetworkProtectionOptionKey.tunnelFailureSimulation] = NSNumber(value: true) } if Self.simulationOptions.isEnabled(.crashFatalError) { Self.simulationOptions.setEnabled(false, option: .crashFatalError) - options[NetworkProtectionOptionKey.tunnelFatalErrorCrashSimulation] = NetworkProtectionOptionValue.true + options[NetworkProtectionOptionKey.tunnelFatalErrorCrashSimulation] = NSNumber(value: true) } if Self.simulationOptions.isEnabled(.controllerFailure) { diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index acfe89a7c0..11442b6ccb 100644 --- a/LocalPackages/DataBrokerProtection/Package.swift +++ b/LocalPackages/DataBrokerProtection/Package.swift @@ -29,7 +29,7 @@ let package = Package( targets: ["DataBrokerProtection"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "77.3.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "77.3.1"), .package(path: "../SwiftUIExtensions") ], targets: [ diff --git a/LocalPackages/NetworkProtectionUI/Package.swift b/LocalPackages/NetworkProtectionUI/Package.swift index 93ceb14ff4..b7433bb2b9 100644 --- a/LocalPackages/NetworkProtectionUI/Package.swift +++ b/LocalPackages/NetworkProtectionUI/Package.swift @@ -15,7 +15,7 @@ let package = Package( targets: ["NetworkProtectionUI"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "77.3.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "77.3.1"), .package(path: "../SwiftUIExtensions") ], targets: [