From 9d404f3298adbf5c9eee75883ff7d17d00d3aa2e Mon Sep 17 00:00:00 2001 From: Federico Cappelli Date: Fri, 22 Mar 2024 12:20:59 +0000 Subject: [PATCH] ios 12 limitation fixed --- .../SubscriptionPagesUserScript.swift | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUserScript.swift b/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUserScript.swift index 89e840c54b..daf9de5b3c 100644 --- a/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUserScript.swift +++ b/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUserScript.swift @@ -116,12 +116,7 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature { case Handlers.backToSettings: return backToSettings case Handlers.getSubscriptionOptions: return getSubscriptionOptions case Handlers.subscriptionSelected: return subscriptionSelected - case Handlers.activateSubscription: - if #available(macOS 12.0, *) { - return activateSubscription - } else { - return nil - } + case Handlers.activateSubscription: return activateSubscription case Handlers.featureSelected: return featureSelected case Handlers.completeStripePayment: return completeStripePayment // Pixel related events @@ -343,7 +338,6 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature { return nil } - @available(macOS 12.0, *) func activateSubscription(params: Any, original: WKScriptMessage) async throws -> Encodable? { Pixel.fire(.privacyProRestorePurchaseOfferPageEntry) @@ -354,12 +348,13 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature { let message = original let actionHandlers = SubscriptionAccessActionHandlers(restorePurchases: { - Task { @MainActor in - await SubscriptionAppStoreRestorer.restoreAppStoreSubscription(mainViewController: mainViewController, windowController: windowControllerManager) - message.webView?.reload() + if #available(macOS 12.0, *) { + Task { @MainActor in + await SubscriptionAppStoreRestorer.restoreAppStoreSubscription(mainViewController: mainViewController, windowController: windowControllerManager) + message.webView?.reload() + } } - }, - openURLHandler: { url in + }, openURLHandler: { url in DispatchQueue.main.async { WindowControllersManager.shared.showTab(with: .subscription(url)) }