Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove VPN upgrade card #1983

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public struct UserDefaultsWrapper<T> {

case networkProtectionExcludedRoutes = "netp.excluded-routes"
case networkProtectionTermsAndConditionsAccepted = "network-protection.waitlist-terms-and-conditions.accepted"
case shouldShowNetworkProtectionSystemExtensionUpgradePrompt = "network-protection.show-system-extension-upgrade-prompt"
case networkProtectionWaitlistSignUpPromptDismissed = "network-protection.waitlist.sign-up-prompt-dismissed"

// Network Protection: Shared Defaults
Expand Down Expand Up @@ -190,6 +189,7 @@ public struct UserDefaultsWrapper<T> {
case networkProtectionConnectionTesterEnabled = "netp.connection-tester-enabled"
case networkProtectionShouldExcludeLocalNetworks = "netp.exclude-local-routes"
case networkProtectionRegistrationKeyValidity = "com.duckduckgo.network-protection.NetworkProtectionTunnelController.registrationKeyValidityKey"
case shouldShowNetworkProtectionSystemExtensionUpgradePrompt = "network-protection.show-system-extension-upgrade-prompt"
}

private let key: Key
Expand Down
34 changes: 3 additions & 31 deletions DuckDuckGo/HomePage/Model/HomePageContinueSetUpModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ extension HomePage.Models {
@UserDefaultsWrapper(key: .firstLaunchDate, defaultValue: Calendar.current.date(byAdding: .month, value: -1, to: Date())!)
private var firstLaunchDate: Date

@UserDefaultsWrapper(key: .shouldShowNetworkProtectionSystemExtensionUpgradePrompt, defaultValue: true)
private var shouldShowNetworkProtectionSystemExtensionUpgradePrompt: Bool

var isMoreOrLessButtonNeeded: Bool {
return featuresMatrix.count > itemsRowCountWhenCollapsed
}
Expand Down Expand Up @@ -182,7 +179,6 @@ extension HomePage.Models {
}
#endif

// swiftlint:disable cyclomatic_complexity
@MainActor func performAction(for featureType: FeatureType) {
switch featureType {
case .defaultBrowser:
Expand All @@ -207,17 +203,12 @@ extension HomePage.Models {
visitSurvey(day: .day7)
case .networkProtectionRemoteMessage(let message):
handle(remoteMessage: message)
case .networkProtectionSystemExtensionUpgrade:
#if NETWORK_PROTECTION
NotificationCenter.default.post(name: .ToggleNetworkProtectionInMainWindow, object: nil)
#endif
case .dataBrokerProtectionWaitlistInvited:
#if DBP
DataBrokerProtectionAppEvents().handleWaitlistInvitedNotification(source: .cardUI)
#endif
}
}
// swiftlint:enable cyclomatic_complexity

func removeItem(for featureType: FeatureType) {
switch featureType {
Expand All @@ -238,15 +229,13 @@ extension HomePage.Models {
networkProtectionRemoteMessaging.dismiss(message: message)
Pixel.fire(.networkProtectionRemoteMessageDismissed(messageID: message.id))
#endif
case .networkProtectionSystemExtensionUpgrade:
shouldShowNetworkProtectionSystemExtensionUpgradePrompt = false
case .dataBrokerProtectionWaitlistInvited:
shouldShowDBPWaitlistInvitedCardUI = false
}
refreshFeaturesMatrix()
}

// swiftlint:disable cyclomatic_complexity function_body_length
// swiftlint:disable:next cyclomatic_complexity
func refreshFeaturesMatrix() {
var features: [FeatureType] = []
#if DBP
Expand All @@ -256,15 +245,6 @@ extension HomePage.Models {
#endif

#if NETWORK_PROTECTION

// Only show the upgrade card to users who have used the VPN before:
let activationStore = DefaultWaitlistActivationDateStore()
if shouldShowNetworkProtectionSystemExtensionUpgradePrompt,
appGroupUserDefaults.networkProtectionOnboardingStatusRawValue != OnboardingStatus.completed.rawValue,
activationStore.daysSinceActivation() != nil {
features.append(.networkProtectionSystemExtensionUpgrade)
}

for message in networkProtectionRemoteMessaging.presentableRemoteMessages() {
features.append(.networkProtectionRemoteMessage(message))
DailyPixel.fire(
Expand Down Expand Up @@ -301,15 +281,14 @@ extension HomePage.Models {
if shouldSurveyDay7BeVisible {
features.append(feature)
}
case .networkProtectionRemoteMessage, .networkProtectionSystemExtensionUpgrade:
case .networkProtectionRemoteMessage:
break // Do nothing, NetP remote messages get appended first
case .dataBrokerProtectionWaitlistInvited:
break // Do nothing. The feature is being set for everyone invited in the waitlist
}
}
featuresMatrix = features.chunked(into: itemsPerRow)
}
// swiftlint:enable cyclomatic_complexity function_body_length

// Helper Functions
@objc private func newTabOpenNotification(_ notification: Notification) {
Expand Down Expand Up @@ -477,7 +456,6 @@ extension HomePage.Models {
case surveyDay0
case surveyDay7
case networkProtectionRemoteMessage(NetworkProtectionRemoteMessage)
case networkProtectionSystemExtensionUpgrade
case dataBrokerProtectionWaitlistInvited

var title: String {
Expand All @@ -496,8 +474,6 @@ extension HomePage.Models {
return UserText.newTabSetUpSurveyDay7CardTitle
case .networkProtectionRemoteMessage(let message):
return message.cardTitle
case .networkProtectionSystemExtensionUpgrade:
return "VPN Update Available"
case .dataBrokerProtectionWaitlistInvited:
return "Personal Information Removal"
}
Expand All @@ -519,8 +495,6 @@ extension HomePage.Models {
return UserText.newTabSetUpSurveyDay7Summary
case .networkProtectionRemoteMessage(let message):
return message.cardDescription
case .networkProtectionSystemExtensionUpgrade:
return "Allow VPN system software again to continue testing Network Protection."
case .dataBrokerProtectionWaitlistInvited:
return "You're invited to try Personal Information Removal beta!"
}
Expand All @@ -542,8 +516,6 @@ extension HomePage.Models {
return UserText.newTabSetUpSurveyDay7Action
case .networkProtectionRemoteMessage(let message):
return message.action.actionTitle
case .networkProtectionSystemExtensionUpgrade:
return "Update VPN"
case .dataBrokerProtectionWaitlistInvited:
return "Get Started"
}
Expand All @@ -565,7 +537,7 @@ extension HomePage.Models {
return NSImage(named: "Survey-128")!.resized(to: iconSize)!
case .surveyDay7:
return NSImage(named: "Survey-128")!.resized(to: iconSize)!
case .networkProtectionRemoteMessage, .networkProtectionSystemExtensionUpgrade:
case .networkProtectionRemoteMessage:
return NSImage(named: "VPN-Ended")!.resized(to: iconSize)!
case .dataBrokerProtectionWaitlistInvited:
return NSImage(named: "DBP-Information-Remover")!.resized(to: iconSize)!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class DataBrokerProtectionInMemoryCacheTests: XCTestCase {

func testCacheDoesNotStoreEmptyNames() throws {
let cache = InMemoryDataCache()
var result = cache.addNameToCurrentUserProfile(DBPUIUserProfileName(first: "", middle: "Jacob", last: "JingleHeimerSchmidt", suffix: nil))
let result = cache.addNameToCurrentUserProfile(DBPUIUserProfileName(first: "", middle: "Jacob", last: "JingleHeimerSchmidt", suffix: nil))

XCTAssertFalse(result, "Result of adding empty name should be `false`")
}
Expand All @@ -68,7 +68,7 @@ final class DataBrokerProtectionInMemoryCacheTests: XCTestCase {

func testCacheDoesNotStoreEmptyAddresses() throws {
let cache = InMemoryDataCache()
var result = cache.addAddressToCurrentUserProfile(DBPUIUserProfileAddress(street: "123 any street", city: "", state: "TX", zipCode: "12345"))
let result = cache.addAddressToCurrentUserProfile(DBPUIUserProfileAddress(street: "123 any street", city: "", state: "TX", zipCode: "12345"))

XCTAssertFalse(result, "Result of adding empty address should be `false`")
}
Expand Down
1 change: 0 additions & 1 deletion UnitTests/HomePage/ContinueSetUpModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ final class ContinueSetUpModelTests: XCTestCase {
UserDefaultsWrapper<Any>.clearAll()
userDefaults.set(Date(), forKey: UserDefaultsWrapper<Date>.Key.firstLaunchDate.rawValue)
userDefaults.set(false, forKey: UserDefaultsWrapper<Date>.Key.homePageUserInteractedWithSurveyDay0.rawValue)
userDefaults.set(false, forKey: UserDefaultsWrapper<Date>.Key.shouldShowNetworkProtectionSystemExtensionUpgradePrompt.rawValue)
capturingDefaultBrowserProvider = CapturingDefaultBrowserProvider()
capturingDataImportProvider = CapturingDataImportProvider()
tabCollectionVM = TabCollectionViewModel()
Expand Down
Loading