Skip to content

Commit

Permalink
PR Feedback (Mostly renaming)
Browse files Browse the repository at this point in the history
  • Loading branch information
aataraxiaa committed Sep 2, 2024
1 parent c554af9 commit 9aa5171
Show file tree
Hide file tree
Showing 19 changed files with 97 additions and 97 deletions.
8 changes: 4 additions & 4 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

dataBrokerProtectionSubscriptionEventHandler.registerForSubscriptionAccountManagerEvents()

let freemiumPIRUserState = DefaultFreemiumPIRUserState(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)
let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)
let pirGatekeeper = DefaultDataBrokerProtectionFeatureGatekeeper(accountManager:
subscriptionManager.accountManager,
freemiumPIRUserState: freemiumPIRUserState)
freemiumPIRUserStateManager: freemiumPIRUserStateManager)

DataBrokerProtectionAppEvents(featureGatekeeper: pirGatekeeper).applicationDidFinishLaunching()

Expand Down Expand Up @@ -429,10 +429,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

NetworkProtectionAppEvents(featureGatekeeper: DefaultVPNFeatureGatekeeper(subscriptionManager: subscriptionManager)).applicationDidBecomeActive()

let freemiumPIRUserState = DefaultFreemiumPIRUserState(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)
let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)
let pirGatekeeper = DefaultDataBrokerProtectionFeatureGatekeeper(accountManager:
subscriptionManager.accountManager,
freemiumPIRUserState: freemiumPIRUserState)
freemiumPIRUserStateManager: freemiumPIRUserStateManager)

DataBrokerProtectionAppEvents(featureGatekeeper: pirGatekeeper).applicationDidBecomeActive()

Expand Down
8 changes: 4 additions & 4 deletions DuckDuckGo/DBP/DataBrokerProtectionFeatureGatekeeper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ struct DefaultDataBrokerProtectionFeatureGatekeeper: DataBrokerProtectionFeature
private let userDefaults: UserDefaults
private let subscriptionAvailability: SubscriptionFeatureAvailability
private let accountManager: AccountManager
private let freemiumPIRUserState: FreemiumPIRUserState
private let freemiumPIRUserStateManager: FreemiumPIRUserStateManager

init(privacyConfigurationManager: PrivacyConfigurationManaging = ContentBlocking.shared.privacyConfigurationManager,
featureDisabler: DataBrokerProtectionFeatureDisabling = DataBrokerProtectionFeatureDisabler(),
pixelHandler: EventMapping<DataBrokerProtectionPixels> = DataBrokerProtectionPixelsHandler(),
userDefaults: UserDefaults = .standard,
subscriptionAvailability: SubscriptionFeatureAvailability = DefaultSubscriptionFeatureAvailability(),
accountManager: AccountManager,
freemiumPIRUserState: FreemiumPIRUserState) {
freemiumPIRUserStateManager: FreemiumPIRUserStateManager) {
self.privacyConfigurationManager = privacyConfigurationManager
self.featureDisabler = featureDisabler
self.pixelHandler = pixelHandler
self.userDefaults = userDefaults
self.subscriptionAvailability = subscriptionAvailability
self.accountManager = accountManager
self.freemiumPIRUserState = freemiumPIRUserState
self.freemiumPIRUserStateManager = freemiumPIRUserStateManager
}

var isUserLocaleAllowed: Bool {
Expand Down Expand Up @@ -86,7 +86,7 @@ struct DefaultDataBrokerProtectionFeatureGatekeeper: DataBrokerProtectionFeature
/// - Returns: Bool indicating prerequisites are satisfied
func arePrerequisitesSatisfied() async -> Bool {

if freemiumPIRUserState.isActiveUser { return true }
if freemiumPIRUserStateManager.isActiveUser { return true }

let entitlements = await accountManager.hasEntitlement(forProductName: .dataBrokerProtection,
cachePolicy: .reloadIgnoringLocalCacheData)
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Freemium/FreemiumDebugMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ final class FreemiumDebugMenu: NSMenuItem {

@objc
func setFreemiumPIROnboardStateEnabled() {
DefaultFreemiumPIRUserState(userDefaults: .dbp, accountManager: Application.appDelegate.subscriptionManager.accountManager).didOnboard = true
DefaultFreemiumPIRUserStateManager(userDefaults: .dbp, accountManager: Application.appDelegate.subscriptionManager.accountManager).didOnboard = true
}

@objc
func setFreemiumPIROnboardStateDisabled() {
DefaultFreemiumPIRUserState(userDefaults: .dbp, accountManager: Application.appDelegate.subscriptionManager.accountManager).didOnboard = false
DefaultFreemiumPIRUserStateManager(userDefaults: .dbp, accountManager: Application.appDelegate.subscriptionManager.accountManager).didOnboard = false
}
}
10 changes: 5 additions & 5 deletions DuckDuckGo/HomePage/View/HomePageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class HomePageViewController: NSViewController {
private let fireViewModel: FireViewModel
private let onboardingViewModel: OnboardingViewModel
private let freemiumPIRFeature: FreemiumPIRFeature
private var freemiumPIRUserState: FreemiumPIRUserState
private var freemiumPIRUserStateManager: FreemiumPIRUserStateManager
private let freemiumPIRPresenter: FreemiumPIRPresenter

private(set) lazy var faviconsFetcherOnboarding: FaviconsFetcherOnboarding? = {
Expand Down Expand Up @@ -70,7 +70,7 @@ final class HomePageViewController: NSViewController {
appearancePreferences: AppearancePreferences = AppearancePreferences.shared,
defaultBrowserPreferences: DefaultBrowserPreferences = DefaultBrowserPreferences.shared,
freemiumPIRFeature: FreemiumPIRFeature,
freemiumPIRUserState: FreemiumPIRUserState,
freemiumPIRUserStateManager: FreemiumPIRUserStateManager,
freemiumPIRPresenter: FreemiumPIRPresenter = DefaultFreemiumPIRPresenter()) {

self.tabCollectionViewModel = tabCollectionViewModel
Expand All @@ -82,7 +82,7 @@ final class HomePageViewController: NSViewController {
self.appearancePreferences = appearancePreferences
self.defaultBrowserPreferences = defaultBrowserPreferences
self.freemiumPIRFeature = freemiumPIRFeature
self.freemiumPIRUserState = freemiumPIRUserState
self.freemiumPIRUserStateManager = freemiumPIRUserStateManager
self.freemiumPIRPresenter = freemiumPIRPresenter

super.init(nibName: nil, bundle: nil)
Expand Down Expand Up @@ -218,9 +218,9 @@ final class HomePageViewController: NSViewController {
private func createPromotionModel() -> PromotionViewModel {
return PromotionViewModel.freemiumPIRPromotion { [weak self] in
// TODO: Remove this

Check failure on line 220 in DuckDuckGo/HomePage/View/HomePageViewController.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

TODOs should be resolved (Remove this) (todo)
self?.freemiumPIRUserState.didOnboard = true
self?.freemiumPIRUserStateManager.didOnboard = true
// ------
self?.freemiumPIRPresenter.showFreemiumPIR(didOnboard: self?.freemiumPIRUserState.didOnboard ?? false,
self?.freemiumPIRPresenter.showFreemiumPIR(didOnboard: self?.freemiumPIRUserStateManager.didOnboard ?? false,
windowControllerManager: WindowControllersManager.shared)
self?.appearancePreferences.didDismissHomePagePromotion = true
} closeAction: { [weak self] in
Expand Down
10 changes: 5 additions & 5 deletions DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class MoreOptionsMenu: NSMenu {
private lazy var sharingMenu: NSMenu = SharingMenu(title: UserText.shareMenuItem)
private var accountManager: AccountManager { subscriptionManager.accountManager }
private let subscriptionManager: SubscriptionManager
private var freemiumPIRUserState: FreemiumPIRUserState
private var freemiumPIRUserStateManager: FreemiumPIRUserStateManager
private let freemiumPIRFeature: FreemiumPIRFeature
private let freemiumPIRPresenter: FreemiumPIRPresenter
private let appearancePreferences: AppearancePreferences
Expand All @@ -79,7 +79,7 @@ final class MoreOptionsMenu: NSMenu {
sharingMenu: NSMenu? = nil,
internalUserDecider: InternalUserDecider,
subscriptionManager: SubscriptionManager,
freemiumPIRUserState: FreemiumPIRUserState,
freemiumPIRUserStateManager: FreemiumPIRUserStateManager,
freemiumPIRFeature: FreemiumPIRFeature,
freemiumPIRPresenter: FreemiumPIRPresenter = DefaultFreemiumPIRPresenter(),
appearancePreferences: AppearancePreferences = .shared) {
Expand All @@ -91,7 +91,7 @@ final class MoreOptionsMenu: NSMenu {
self.subscriptionFeatureAvailability = subscriptionFeatureAvailability
self.internalUserDecider = internalUserDecider
self.subscriptionManager = subscriptionManager
self.freemiumPIRUserState = freemiumPIRUserState
self.freemiumPIRUserStateManager = freemiumPIRUserStateManager
self.freemiumPIRFeature = freemiumPIRFeature
self.freemiumPIRPresenter = freemiumPIRPresenter
self.appearancePreferences = appearancePreferences
Expand Down Expand Up @@ -261,9 +261,9 @@ final class MoreOptionsMenu: NSMenu {
@objc func openFreemiumPIR(_ sender: NSMenuItem) {

// TODO: Remove this

Check failure on line 263 in DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

TODOs should be resolved (Remove this) (todo)
freemiumPIRUserState.didOnboard = true
freemiumPIRUserStateManager.didOnboard = true
// ------
freemiumPIRPresenter.showFreemiumPIR(didOnboard: freemiumPIRUserState.didOnboard, windowControllerManager: WindowControllersManager.shared)
freemiumPIRPresenter.showFreemiumPIR(didOnboard: freemiumPIRUserStateManager.didOnboard, windowControllerManager: WindowControllersManager.shared)
appearancePreferences.isHomePagePromotionVisible = false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,14 @@ final class NavigationBarViewController: NSViewController {

@IBAction func optionsButtonAction(_ sender: NSButton) {
let internalUserDecider = NSApp.delegateTyped.internalUserDecider
let freemiumPIRUserState = DefaultFreemiumPIRUserState(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)
let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)
let freemiumPIRFeature = DefaultFreemiumPIRFeature(subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager)
let menu = MoreOptionsMenu(tabCollectionViewModel: tabCollectionViewModel,
passwordManagerCoordinator: PasswordManagerCoordinator.shared,
vpnFeatureGatekeeper: DefaultVPNFeatureGatekeeper(subscriptionManager: subscriptionManager),
internalUserDecider: internalUserDecider,
subscriptionManager: subscriptionManager,
freemiumPIRUserState: freemiumPIRUserState,
freemiumPIRUserStateManager: freemiumPIRUserStateManager,
freemiumPIRFeature: freemiumPIRFeature)

menu.actionDelegate = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ final class RemoteMessagingConfigMatcherProvider: RemoteMessagingConfigMatcherPr

let deprecatedRemoteMessageStorage = DefaultSurveyRemoteMessagingStorage.surveys()

let freemiumPIRUserState = DefaultFreemiumPIRUserState(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)
let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)

return RemoteMessagingConfigMatcher(
appAttributeMatcher: AppAttributeMatcher(statisticsStore: statisticsStore,
Expand All @@ -164,7 +164,7 @@ final class RemoteMessagingConfigMatcherProvider: RemoteMessagingConfigMatcherPr
hasCustomHomePage: startupPreferencesPersistor().launchToCustomHomePage,
isDuckPlayerOnboarded: duckPlayerPreferencesPersistor.youtubeOverlayAnyButtonPressed,
isDuckPlayerEnabled: duckPlayerPreferencesPersistor.duckPlayerModeBool != false,
isCurrentFreemiumPIRUser: freemiumPIRUserState.isActiveUser,
isCurrentFreemiumPIRUser: freemiumPIRUserStateManager.isActiveUser,
dismissedDeprecatedMacRemoteMessageIds: deprecatedRemoteMessageStorage.dismissedMessageIDs()
),
percentileStore: RemoteMessagingPercentileUserDefaultsStore(keyValueStore: UserDefaults.standard),
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Tab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -676,10 +676,10 @@ final class BrowserTabViewController: NSViewController {
return homePageViewController ?? {
let subscriptionManager = Application.appDelegate.subscriptionManager
let freemiumPIRFeature = DefaultFreemiumPIRFeature(subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager)
let freemiumPIRUserState = DefaultFreemiumPIRUserState(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)
let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp, accountManager: subscriptionManager.accountManager)
let homePageViewController = HomePageViewController(tabCollectionViewModel: tabCollectionViewModel, bookmarkManager: bookmarkManager,
freemiumPIRFeature: freemiumPIRFeature,
freemiumPIRUserState: freemiumPIRUserState)
freemiumPIRUserStateManager: freemiumPIRUserStateManager)
self.homePageViewController = homePageViewController
return homePageViewController
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public class DataBrokerProtectionAgentManagerProvider {
emailService: emailService,
captchaService: captchaService)

let freemiumPIRUserState = DefaultFreemiumPIRUserState(userDefaults: .dbp, accountManager: accountManager)
let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp, accountManager: accountManager)

let agentstopper = DefaultDataBrokerProtectionAgentStopper(dataManager: dataManager,
entitlementMonitor: DataBrokerProtectionEntitlementMonitor(),
authenticationManager: authenticationManager,
pixelHandler: pixelHandler,
freemiumPIRUserState: freemiumPIRUserState)
freemiumPIRUserStateManager: freemiumPIRUserStateManager)

let operationDependencies = DefaultDataBrokerOperationDependencies(
database: dataManager.database,
Expand All @@ -100,7 +100,7 @@ public class DataBrokerProtectionAgentManagerProvider {
operationDependencies: operationDependencies,
pixelHandler: pixelHandler,
agentStopper: agentstopper,
freemiumPIRUserState: freemiumPIRUserState)
freemiumPIRUserStateManager: freemiumPIRUserStateManager)
}
}

Expand All @@ -114,7 +114,7 @@ public final class DataBrokerProtectionAgentManager {
private let operationDependencies: DataBrokerOperationDependencies
private let pixelHandler: EventMapping<DataBrokerProtectionPixels>
private let agentStopper: DataBrokerProtectionAgentStopper
private let freemiumPIRUserState: FreemiumPIRUserState
private let freemiumPIRUserStateManager: FreemiumPIRUserStateManager

// Used for debug functions only, so not injected
private lazy var browserWindowManager = BrowserWindowManager()
Expand All @@ -129,7 +129,7 @@ public final class DataBrokerProtectionAgentManager {
operationDependencies: DataBrokerOperationDependencies,
pixelHandler: EventMapping<DataBrokerProtectionPixels>,
agentStopper: DataBrokerProtectionAgentStopper,
freemiumPIRUserState: FreemiumPIRUserState
freemiumPIRUserStateManager: FreemiumPIRUserStateManager
) {
self.userNotificationService = userNotificationService
self.activityScheduler = activityScheduler
Expand All @@ -139,7 +139,7 @@ public final class DataBrokerProtectionAgentManager {
self.operationDependencies = operationDependencies
self.pixelHandler = pixelHandler
self.agentStopper = agentStopper
self.freemiumPIRUserState = freemiumPIRUserState
self.freemiumPIRUserStateManager = freemiumPIRUserStateManager

self.activityScheduler.delegate = self
self.ipcServer.serverDelegate = self
Expand Down Expand Up @@ -197,7 +197,7 @@ private extension DataBrokerProtectionAgentManager {
func startFreemiumOrSubscriptionScheduledOperations(showWebView: Bool,
operationDependencies: DataBrokerOperationDependencies,
completion: ((DataBrokerProtectionAgentErrorCollection?) -> Void)?) {
if freemiumPIRUserState.isActiveUser {
if freemiumPIRUserStateManager.isActiveUser {
queueManager.startScheduledScanOperationsIfPermitted(showWebView: showWebView, operationDependencies: operationDependencies, completion: completion)
} else {
queueManager.startScheduledAllOperationsIfPermitted(showWebView: showWebView, operationDependencies: operationDependencies, completion: completion)
Expand Down
Loading

0 comments on commit 9aa5171

Please sign in to comment.