From e37ba00598bdfcb2669a445628b66af6aee850e2 Mon Sep 17 00:00:00 2001 From: Michal Smaga Date: Fri, 22 Mar 2024 22:27:43 +0100 Subject: [PATCH] Rework check for purchase allowed --- DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift | 2 ++ .../UserScripts/Subscription/SubscriptionPagesUserScript.swift | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift index 0ab306100c..cd80f9fff1 100644 --- a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift +++ b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift @@ -337,6 +337,8 @@ final class MoreOptionsMenu: NSMenu { var items: [NSMenuItem] = [] #if SUBSCRIPTION + + let subscriptionFeatureAvailability = DefaultSubscriptionFeatureAvailability() #endif diff --git a/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUserScript.swift b/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUserScript.swift index daf9de5b3c..5039db9ade 100644 --- a/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUserScript.swift +++ b/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUserScript.swift @@ -185,7 +185,7 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature { } func getSubscriptionOptions(params: Any, original: WKScriptMessage) async throws -> Encodable? { - guard await NSApp.delegateTyped.subscriptionFeatureAvailability.isSubscriptionPurchaseAllowed else { return SubscriptionOptions.empty } + guard DefaultSubscriptionFeatureAvailability().isSubscriptionPurchaseAllowed else { return SubscriptionOptions.empty } if SubscriptionPurchaseEnvironment.current == .appStore { if #available(macOS 12.0, *) {