Bläddra i källkod

Allow premium users to open the upgrade paywall and confirm before repurchasing.

This keeps the upgrade path available for plan changes while adding an explicit consent step when premium access is already active.

Made-with: Cursor
huzaifahayat12 3 månader sedan
förälder
incheckning
9dc946cfd4
1 ändrade filer med 16 tillägg och 10 borttagningar
  1. 16 10
      meetings_app/ViewController.swift

+ 16 - 10
meetings_app/ViewController.swift

@@ -470,7 +470,7 @@ private extension ViewController {
 
     @objc private func premiumButtonClicked(_ sender: NSClickGestureRecognizer) {
         if storeKitCoordinator.hasPremiumAccess {
-            openManageSubscriptions()
+            showPaywall(upgradeFlow: true, preferredPlan: .lifetime)
         } else {
             showPaywall()
         }
@@ -800,6 +800,15 @@ private extension ViewController {
         alert.runModal()
     }
 
+    private func confirmPremiumUpgrade() -> Bool {
+        let alert = NSAlert()
+        alert.messageText = "Already Premium"
+        alert.informativeText = "You are already premium. Do you want to continue with this purchase?"
+        alert.addButton(withTitle: "Continue")
+        alert.addButton(withTitle: "Cancel")
+        return alert.runModal() == .alertFirstButtonReturn
+    }
+
     private func showPaywall(upgradeFlow: Bool = false, preferredPlan: PremiumPlan? = nil) {
         paywallUpgradeFlowEnabled = upgradeFlow
         if let preferredPlan {
@@ -1094,6 +1103,9 @@ private extension ViewController {
             }
             return
         }
+        if paywallUpgradeFlowEnabled && storeKitCoordinator.hasPremiumAccess && !confirmPremiumUpgrade() {
+            return
+        }
         paywallPurchaseTask?.cancel()
         updatePaywallContinueState(isLoading: true)
         let selectedPlan = selectedPremiumPlan
@@ -1132,15 +1144,9 @@ private extension ViewController {
             paywallContinueLabel?.stringValue = "Premium Active"
             paywallContinueButton?.alphaValue = 0.75
         } else if paywallUpgradeFlowEnabled && storeKitCoordinator.hasPremiumAccess {
-            if selectedPremiumPlan == .lifetime {
-                paywallContinueEnabled = true
-                paywallContinueLabel?.stringValue = "Continue"
-                paywallContinueButton?.alphaValue = 1.0
-            } else {
-                paywallContinueEnabled = false
-                paywallContinueLabel?.stringValue = "Select Lifetime to Upgrade"
-                paywallContinueButton?.alphaValue = 0.75
-            }
+            paywallContinueEnabled = true
+            paywallContinueLabel?.stringValue = "Continue"
+            paywallContinueButton?.alphaValue = 1.0
         } else {
             paywallContinueEnabled = true
             paywallContinueLabel?.stringValue = "Continue"