From 028f34fb156a6932f85d87e68a71fdb5b269248d Mon Sep 17 00:00:00 2001 From: Michal Smaga Date: Fri, 22 Mar 2024 23:10:21 +0100 Subject: [PATCH 1/2] Hide PrivacyPro when using App Store and no products are found --- .../NavigationBar/View/MoreOptionsMenu.swift | 14 ++++++++++++-- .../Preferences/Model/PreferencesSection.swift | 8 ++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift index cd80f9fff1..990514f3d3 100644 --- a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift +++ b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift @@ -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 @@ -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: "") diff --git a/DuckDuckGo/Preferences/Model/PreferencesSection.swift b/DuckDuckGo/Preferences/Model/PreferencesSection.swift index 9274a723dd..81b9739aae 100644 --- a/DuckDuckGo/Preferences/Model/PreferencesSection.swift +++ b/DuckDuckGo/Preferences/Model/PreferencesSection.swift @@ -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 From df25b48d0b2a7d6cefaafd6fd273b427de71ae34 Mon Sep 17 00:00:00 2001 From: Michal Smaga Date: Fri, 22 Mar 2024 23:34:27 +0100 Subject: [PATCH 2/2] It is not necessary to hide active subscription items as they are already bought --- DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift | 7 ------- 1 file changed, 7 deletions(-) diff --git a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift index 990514f3d3..3ae0a5ab01 100644 --- a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift +++ b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift @@ -338,13 +338,6 @@ final class MoreOptionsMenu: NSMenu { #if SUBSCRIPTION let subscriptionFeatureAvailability = DefaultSubscriptionFeatureAvailability() - - if subscriptionFeatureAvailability.isFeatureAvailable { - switch (SubscriptionPurchaseEnvironment.current, SubscriptionPurchaseEnvironment.canPurchase) { - case (.appStore, false): return [] - default: break - } - } #endif #if NETWORK_PROTECTION