Ver código fonte

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 1 semana atrás
pai
commit
9dc946cfd4
1 arquivos alterados com 16 adições e 10 exclusões
  1. 16 10
      meetings_app/ViewController.swift

+ 16 - 10
meetings_app/ViewController.swift

@@ -470,7 +470,7 @@ private extension ViewController {
470 470
 
471 471
     @objc private func premiumButtonClicked(_ sender: NSClickGestureRecognizer) {
472 472
         if storeKitCoordinator.hasPremiumAccess {
473
-            openManageSubscriptions()
473
+            showPaywall(upgradeFlow: true, preferredPlan: .lifetime)
474 474
         } else {
475 475
             showPaywall()
476 476
         }
@@ -800,6 +800,15 @@ private extension ViewController {
800 800
         alert.runModal()
801 801
     }
802 802
 
803
+    private func confirmPremiumUpgrade() -> Bool {
804
+        let alert = NSAlert()
805
+        alert.messageText = "Already Premium"
806
+        alert.informativeText = "You are already premium. Do you want to continue with this purchase?"
807
+        alert.addButton(withTitle: "Continue")
808
+        alert.addButton(withTitle: "Cancel")
809
+        return alert.runModal() == .alertFirstButtonReturn
810
+    }
811
+
803 812
     private func showPaywall(upgradeFlow: Bool = false, preferredPlan: PremiumPlan? = nil) {
804 813
         paywallUpgradeFlowEnabled = upgradeFlow
805 814
         if let preferredPlan {
@@ -1094,6 +1103,9 @@ private extension ViewController {
1094 1103
             }
1095 1104
             return
1096 1105
         }
1106
+        if paywallUpgradeFlowEnabled && storeKitCoordinator.hasPremiumAccess && !confirmPremiumUpgrade() {
1107
+            return
1108
+        }
1097 1109
         paywallPurchaseTask?.cancel()
1098 1110
         updatePaywallContinueState(isLoading: true)
1099 1111
         let selectedPlan = selectedPremiumPlan
@@ -1132,15 +1144,9 @@ private extension ViewController {
1132 1144
             paywallContinueLabel?.stringValue = "Premium Active"
1133 1145
             paywallContinueButton?.alphaValue = 0.75
1134 1146
         } else if paywallUpgradeFlowEnabled && storeKitCoordinator.hasPremiumAccess {
1135
-            if selectedPremiumPlan == .lifetime {
1136
-                paywallContinueEnabled = true
1137
-                paywallContinueLabel?.stringValue = "Continue"
1138
-                paywallContinueButton?.alphaValue = 1.0
1139
-            } else {
1140
-                paywallContinueEnabled = false
1141
-                paywallContinueLabel?.stringValue = "Select Lifetime to Upgrade"
1142
-                paywallContinueButton?.alphaValue = 0.75
1143
-            }
1147
+            paywallContinueEnabled = true
1148
+            paywallContinueLabel?.stringValue = "Continue"
1149
+            paywallContinueButton?.alphaValue = 1.0
1144 1150
         } else {
1145 1151
             paywallContinueEnabled = true
1146 1152
             paywallContinueLabel?.stringValue = "Continue"