From 864bcf9cfef11ad92415ff25c273bac62a92e3c3 Mon Sep 17 00:00:00 2001 From: Graeme Arthur <2030310+graeme@users.noreply.github.com> Date: Fri, 15 Dec 2023 18:15:13 +0100 Subject: [PATCH] Add a feature flag for the location prefs --- DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift | 4 ++++ DuckDuckGo/Preferences/Model/VPNPreferencesModel.swift | 6 +++++- DuckDuckGo/Preferences/View/PreferencesVPNView.swift | 8 +++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift b/DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift index 8b784addef..66fba3ac63 100644 --- a/DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift +++ b/DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift @@ -25,6 +25,8 @@ public enum FeatureFlag: String { /// Add experimental atb parameter to SERP queries for internal users to display Privacy Reminder /// https://app.asana.com/0/1199230911884351/1205979030848528/f case appendAtbToSerpQueries + + case vpnGeoswitching } extension FeatureFlag: FeatureFlagSourceProviding { @@ -34,6 +36,8 @@ extension FeatureFlag: FeatureFlagSourceProviding { return .internalOnly case .appendAtbToSerpQueries: return .internalOnly + case .vpnGeoswitching: + return .internalOnly } } } diff --git a/DuckDuckGo/Preferences/Model/VPNPreferencesModel.swift b/DuckDuckGo/Preferences/Model/VPNPreferencesModel.swift index 8f8d4e627e..54c2a5420e 100644 --- a/DuckDuckGo/Preferences/Model/VPNPreferencesModel.swift +++ b/DuckDuckGo/Preferences/Model/VPNPreferencesModel.swift @@ -23,9 +23,11 @@ import Combine import Foundation import NetworkProtection import NetworkProtectionUI +import BrowserServicesKit final class VPNPreferencesModel: ObservableObject { + let shouldShowLocationItem: Bool @Published var locationItem: VPNLocationPreferenceItemModel @Published var alwaysON = true @@ -68,7 +70,8 @@ final class VPNPreferencesModel: ObservableObject { private var cancellables = Set() init(settings: VPNSettings = .init(defaults: .netP), - defaults: UserDefaults = .netP) { + defaults: UserDefaults = .netP, + featureFlagger: FeatureFlagger = NSApp.delegateTyped.featureFlagger) { self.settings = settings connectOnLogin = settings.connectOnLogin @@ -78,6 +81,7 @@ final class VPNPreferencesModel: ObservableObject { showUninstallVPN = defaults.networkProtectionOnboardingStatus != .default onboardingStatus = defaults.networkProtectionOnboardingStatus locationItem = VPNLocationPreferenceItemModel(selectedLocation: settings.selectedLocation) + shouldShowLocationItem = featureFlagger.isFeatureOn(.vpnGeoswitching) subscribeToOnboardingStatusChanges(defaults: defaults) subscribeToLocationSettingChanges() diff --git a/DuckDuckGo/Preferences/View/PreferencesVPNView.swift b/DuckDuckGo/Preferences/View/PreferencesVPNView.swift index ccdf767d0e..7b16780933 100644 --- a/DuckDuckGo/Preferences/View/PreferencesVPNView.swift +++ b/DuckDuckGo/Preferences/View/PreferencesVPNView.swift @@ -33,9 +33,11 @@ extension Preferences { TextMenuTitle(text: UserText.vpn) - PreferencePaneSection { - TextMenuItemHeader(text: UserText.vpnLocationTitle) - VPNLocationPreferenceItem(model: model.locationItem) + if model.shouldShowLocationItem { + PreferencePaneSection { + TextMenuItemHeader(text: UserText.vpnLocationTitle) + VPNLocationPreferenceItem(model: model.locationItem) + } } // SECTION: Manage VPN