Skip to content

Commit

Permalink
Hide PrivacyPro when using App Store and no products are found
Browse files Browse the repository at this point in the history
  • Loading branch information
miasma13 committed Mar 22, 2024
1 parent e37ba00 commit 028f34f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 12 additions & 2 deletions DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,14 @@ final class MoreOptionsMenu: NSMenu {
var items: [NSMenuItem] = []

#if SUBSCRIPTION


let subscriptionFeatureAvailability = DefaultSubscriptionFeatureAvailability()

if subscriptionFeatureAvailability.isFeatureAvailable {
switch (SubscriptionPurchaseEnvironment.current, SubscriptionPurchaseEnvironment.canPurchase) {
case (.appStore, false): return []
default: break
}
}
#endif

#if NETWORK_PROTECTION
Expand Down Expand Up @@ -437,6 +442,11 @@ final class MoreOptionsMenu: NSMenu {

#if SUBSCRIPTION
private func makeInactiveSubscriptionItems() -> [NSMenuItem] {
switch (SubscriptionPurchaseEnvironment.current, SubscriptionPurchaseEnvironment.canPurchase) {
case (.appStore, false): return []
default: break
}

let privacyProItem = NSMenuItem(title: UserText.subscriptionOptionsMenuItem,
action: #selector(openSubscriptionPurchasePage(_:)),
keyEquivalent: "")
Expand Down
8 changes: 6 additions & 2 deletions DuckDuckGo/Preferences/Model/PreferencesSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ struct PreferencesSection: Hashable, Identifiable {

#if SUBSCRIPTION
if DefaultSubscriptionFeatureAvailability().isFeatureAvailable {
let subscriptionPanes: [PreferencePaneIdentifier] = [.subscription]
sections.insert(.init(id: .privacyPro, panes: subscriptionPanes), at: 1)
switch (SubscriptionPurchaseEnvironment.current, SubscriptionPurchaseEnvironment.canPurchase) {
case (.appStore, false): break
default:
let subscriptionPanes: [PreferencePaneIdentifier] = [.subscription]
sections.insert(.init(id: .privacyPro, panes: subscriptionPanes), at: 1)
}
}
#endif

Expand Down

0 comments on commit 028f34f

Please sign in to comment.