Przeglądaj źródła

Fix upgrade paywall and premium footer actions.

Co-authored-by: Cursor <cursoragent@cursor.com>
huzaifahayat12 2 miesięcy temu
rodzic
commit
1207347da0

+ 9 - 1
google_apps/AppDelegate.swift

@@ -69,7 +69,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
     /// Presents the premium paywall as a non-draggable, non-resizable child window that exactly covers `parent`.
     @MainActor
     func presentPremiumPaywall(over parent: NSWindow? = nil, storeAsStartupPaywall: Bool = false) {
-        guard !PremiumStore.shared.isPremiumUnlocked else { return }
+        if storeAsStartupPaywall {
+            // Startup paywall is only for non-premium users.
+            guard !PremiumStore.shared.isPremiumUnlocked else { return }
+        } else {
+            // Allow showing the paywall for the yearly->lifetime upgrade flow.
+            if PremiumStore.shared.isPremiumUnlocked && PremiumStore.shared.activePremiumProductID != .yearly {
+                return
+            }
+        }
         guard let parentWindow = parent ?? launcherWindow else { return }
 
         if let existing = startupPaywallWindow, existing.isVisible {

+ 33 - 3
google_apps/PremiumFeaturesView.swift

@@ -353,7 +353,18 @@ struct PremiumFeaturesView: View {
 
     private var compactFooterLinks: some View {
         VStack(spacing: 10) {
-            continueWithFreeButton
+            if premiumStore.isPremiumUnlocked {
+                HStack {
+                    footerActionButton("Manage Subscription") { openManageSubscriptions() }
+                    Spacer()
+                    footerActionButton(premiumStore.restoreInProgress ? "Restoring…" : "Restore Purchase") {
+                        Task { await premiumStore.restorePurchases() }
+                    }
+                    .disabled(premiumStore.restoreInProgress || premiumStore.purchaseInProgress)
+                }
+            } else {
+                continueWithFreeButton
+            }
 
             HStack {
                 Spacer()
@@ -376,8 +387,18 @@ struct PremiumFeaturesView: View {
                 .padding(.top, 6)
 
             HStack {
-                footerActionButton("Continue with Free") { dismissPremiumUI() }
-                Spacer(minLength: 18)
+                if premiumStore.isPremiumUnlocked {
+                    footerActionButton("Manage Subscription") { openManageSubscriptions() }
+                    Spacer(minLength: 18)
+                    footerActionButton(premiumStore.restoreInProgress ? "Restoring…" : "Restore Purchase") {
+                        Task { await premiumStore.restorePurchases() }
+                    }
+                    .disabled(premiumStore.restoreInProgress || premiumStore.purchaseInProgress)
+                    Spacer(minLength: 18)
+                } else {
+                    footerActionButton("Continue with Free") { dismissPremiumUI() }
+                    Spacer(minLength: 18)
+                }
                 footerActionButton("Privacy Policy") { openExternalPage(ExternalPage.privacy) }
                 Spacer(minLength: 18)
                 footerActionButton("Support") { openExternalPage(ExternalPage.support) }
@@ -389,6 +410,15 @@ struct PremiumFeaturesView: View {
         .padding(.top, 8)
     }
 
+    private func openManageSubscriptions() {
+        let appStoreURL = URL(string: "macappstore://apps.apple.com/account/subscriptions")!
+        if NSWorkspace.shared.open(appStoreURL) {
+            return
+        }
+        let webURL = URL(string: "https://apps.apple.com/account/subscriptions")!
+        _ = NSWorkspace.shared.open(webURL)
+    }
+
     private var continueWithFreeButton: some View {
         Button("Continue with Free") {
             dismissPremiumUI()