From 69680b0ea495f7c5d6fe7c2866e4cdd6f71fd80b Mon Sep 17 00:00:00 2001 From: Graeme Arthur Date: Wed, 10 Apr 2024 18:34:47 +0200 Subject: [PATCH] Fix VPN bug: Nearest city breaks register requests (#2589) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task/Issue URL: https://app.asana.com/0/1203137811378537/1207044169885477/f **Description**: Due to a bug in the VPNLocationViewModel, we were using the string “Nearest” as a city ID which ended up making it to the `register` request. This only happens when we explicitly select Nearest rather than just selecting the country (which has the same effect). **Steps to test this PR**: 1. Make sure you’re hitting the production VPN environment (so you get the full countries + cities). 2. Go to VPN Location screen 3. Go to a country with multiple cities (currently only the US) and select any specific city 4. Now select Nearest (explicitly using the drop-down) 5. Go to the VPN management popover (e.g nav bar → … → VPN) and connect **Expected** VPN connects to the nearest city in that country --- ###### Internal references: [Pull Request Review Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f) [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) [Pull Request Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f) --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- .../BothAppTargets/VPNLocation/VPNLocationViewModel.swift | 3 ++- LocalPackages/DataBrokerProtection/Package.swift | 2 +- LocalPackages/NetworkProtectionMac/Package.swift | 2 +- LocalPackages/SubscriptionUI/Package.swift | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 2bbc99a10b..43f4bd6b34 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -14448,7 +14448,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 133.0.0; + version = "133.0.0-1"; }; }; 9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 46c657c96d..8ab89dd501 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { - "revision" : "c0b0cb55e7ac2f69d10452e1a5c06713155d798e", - "version" : "133.0.0" + "revision" : "ab719a6a786a3c4e898496c13ca76a470e89893b", + "version" : "133.0.0-1" } }, { diff --git a/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/VPNLocation/VPNLocationViewModel.swift b/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/VPNLocation/VPNLocationViewModel.swift index 01a39e35f4..3368da5066 100644 --- a/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/VPNLocation/VPNLocationViewModel.swift +++ b/DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/VPNLocation/VPNLocationViewModel.swift @@ -80,7 +80,8 @@ final class VPNLocationViewModel: ObservableObject { func onCountryItemSelection(id: String, cityId: String? = nil) async { DailyPixel.fire(pixel: .networkProtectionGeoswitchingSetCustom, frequency: .dailyAndCount) - let location = NetworkProtectionSelectedLocation(country: id, city: cityId) + let city = cityId == VPNCityItemModel.nearest.id ? nil : cityId + let location = NetworkProtectionSelectedLocation(country: id, city: city) selectedLocation = .location(location) await reloadList() } diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index 46c094664b..78a7506d5e 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: "133.0.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "133.0.0-1"), .package(path: "../PixelKit"), .package(path: "../SwiftUIExtensions"), .package(path: "../XPCHelper"), diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift index d0ea0235c3..9667eea790 100644 --- a/LocalPackages/NetworkProtectionMac/Package.swift +++ b/LocalPackages/NetworkProtectionMac/Package.swift @@ -31,7 +31,7 @@ let package = Package( .library(name: "NetworkProtectionUI", targets: ["NetworkProtectionUI"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "133.0.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "133.0.0-1"), .package(path: "../XPCHelper"), .package(path: "../SwiftUIExtensions"), .package(path: "../LoginItems"), diff --git a/LocalPackages/SubscriptionUI/Package.swift b/LocalPackages/SubscriptionUI/Package.swift index 556d4f308e..808b065230 100644 --- a/LocalPackages/SubscriptionUI/Package.swift +++ b/LocalPackages/SubscriptionUI/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["SubscriptionUI"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "133.0.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "133.0.0-1"), .package(path: "../SwiftUIExtensions") ], targets: [