Skip to content

Commit

Permalink
Add a feature flag for the location prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
graeme committed Dec 15, 2023
1 parent 9278ee9 commit 864bcf9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,6 +36,8 @@ extension FeatureFlag: FeatureFlagSourceProviding {
return .internalOnly
case .appendAtbToSerpQueries:
return .internalOnly
case .vpnGeoswitching:
return .internalOnly
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion DuckDuckGo/Preferences/Model/VPNPreferencesModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -68,7 +70,8 @@ final class VPNPreferencesModel: ObservableObject {
private var cancellables = Set<AnyCancellable>()

init(settings: VPNSettings = .init(defaults: .netP),
defaults: UserDefaults = .netP) {
defaults: UserDefaults = .netP,
featureFlagger: FeatureFlagger = NSApp.delegateTyped.featureFlagger) {
self.settings = settings

connectOnLogin = settings.connectOnLogin
Expand All @@ -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()
Expand Down
8 changes: 5 additions & 3 deletions DuckDuckGo/Preferences/View/PreferencesVPNView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 864bcf9

Please sign in to comment.