Skip to content

Commit

Permalink
Connect thank you message to DBP method (#2456)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1204167627774280/1206824862073996/f
Tech Design URL:
CC:

**Description**:
Connect thank you message to DBP method
  • Loading branch information
Bunn authored Mar 19, 2024
1 parent 59a72ea commit 04c2026
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions DuckDuckGo/DBP/DataBrokerProtectionFeatureVisibility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protocol DataBrokerProtectionFeatureVisibility {
func disableAndDeleteForAllUsers()
func disableAndDeleteForWaitlistUsers()
func isPrivacyProEnabled() -> Bool
func isEligibleForThankYouMessage() -> Bool
}

struct DefaultDataBrokerProtectionFeatureVisibility: DataBrokerProtectionFeatureVisibility {
Expand Down Expand Up @@ -91,6 +92,10 @@ struct DefaultDataBrokerProtectionFeatureVisibility: DataBrokerProtectionFeature
DataBrokerProtectionWaitlist().waitlistStorage.isWaitlistUser
}

private var wasWaitlistUser: Bool {
DataBrokerProtectionWaitlist().waitlistStorage.getWaitlistInviteCode() != nil
}

func isPrivacyProEnabled() -> Bool {
#if SUBSCRIPTION
return NSApp.delegateTyped.subscriptionFeatureAvailability.isFeatureAvailable
Expand All @@ -100,6 +105,10 @@ struct DefaultDataBrokerProtectionFeatureVisibility: DataBrokerProtectionFeature

}

func isEligibleForThankYouMessage() -> Bool {
return wasWaitlistUser && isPrivacyProEnabled()
}

func disableAndDeleteForAllUsers() {
featureDisabler.disableAndDelete()

Expand All @@ -117,8 +126,6 @@ struct DefaultDataBrokerProtectionFeatureVisibility: DataBrokerProtectionFeature

/// Returns true if a cleanup was performed, false otherwise
func cleanUpDBPForPrivacyProIfNecessary() -> Bool {
let wasWaitlistUser = DataBrokerProtectionWaitlist().waitlistStorage.getWaitlistInviteCode() != nil

if isPrivacyProEnabled() && wasWaitlistUser && !dataBrokerProtectionCleanedUpFromWaitlistToPrivacyPro {
disableAndDeleteForWaitlistUsers()
dataBrokerProtectionCleanedUpFromWaitlistToPrivacyPro = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class WaitlistThankYouPromptPresenter {
self.init(isVPNBetaTester: {
return false
}, isPIRBetaTester: {
return false
return DefaultDataBrokerProtectionFeatureVisibility().isEligibleForThankYouMessage()
})
}

Expand Down

0 comments on commit 04c2026

Please sign in to comment.