Skip to content

Commit

Permalink
Fix VPN bug: Nearest city breaks register requests (#2589)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
graeme authored Apr 10, 2024
1 parent 86f799f commit 69680b0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SubscriptionUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 69680b0

Please sign in to comment.