瀏覽代碼

Gate Pro-only actions behind the subscription paywall.

Non-subscribers can browse CV templates and profiles, but generating a CV, editing profiles, and job search prompt the premium plans sheet.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 2 月之前
父節點
當前提交
b4cc5e5fad
共有 1 個文件被更改,包括 16 次插入9 次删除
  1. 16 9
      App for Indeed/Views/DashboardView.swift

+ 16 - 9
App for Indeed/Views/DashboardView.swift

@@ -454,6 +454,16 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
         }
     }
 
+    /// Returns `false` and presents the paywall when the user does not have an active Pro subscription.
+    @discardableResult
+    private func ensureProAccess() -> Bool {
+        guard SubscriptionStore.shared.isProActive else {
+            presentPremiumPlansSheet()
+            return false
+        }
+        return true
+    }
+
     private func presentPremiumPlansSheet() {
         guard let hostWindow = window else { return }
 
@@ -1346,7 +1356,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
         ])
 
         cvMakerPageView.onContinueToProfileSelection = { [weak self] template in
-            guard let self else { return }
+            guard let self, self.ensureProAccess() else { return }
             self.pendingCVTemplate = template
             self.profilesListPageView.setPendingCVTemplateDisplayName(template.name)
             self.selectProfileSidebarForCVMakerFlow()
@@ -1420,6 +1430,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
     }
 
     private func presentCVDocumentPreview(profile: SavedProfile, template: CVTemplate) {
+        guard ensureProAccess() else { return }
         isCVDocumentPreviewPresented = true
         cvFilledPreviewPageView.configure(profile: profile, template: template)
         cvFilledPreviewPageView.isHidden = false
@@ -1436,6 +1447,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
     }
 
     private func presentProfileEditor(existingID: UUID?) {
+        guard ensureProAccess() else { return }
         if isCVDocumentPreviewPresented {
             dismissCVDocumentPreview()
         }
@@ -1772,10 +1784,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
     }
 
     @objc private func didSubmitSearch() {
-        guard SubscriptionStore.shared.isProActive else {
-            presentPremiumPlansSheet()
-            return
-        }
+        guard ensureProAccess() else { return }
         let prompt = jobKeywordsField.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
         guard !prompt.isEmpty, !isAwaitingResponse else { return }
         let isContinuation = isContinuationPrompt(prompt)
@@ -1892,6 +1901,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
     }
 
     private func focusSearchField(seed: String) {
+        guard ensureProAccess() else { return }
         jobKeywordsField.stringValue = seed
         window?.makeFirstResponder(jobKeywordsField)
         if let editor = jobKeywordsField.window?.fieldEditor(true, for: jobKeywordsField) as? NSTextView {
@@ -1900,10 +1910,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
     }
 
     @objc private func didTapLoadMoreJobs() {
-        guard SubscriptionStore.shared.isProActive else {
-            presentPremiumPlansSheet()
-            return
-        }
+        guard ensureProAccess() else { return }
         let prompt = "Show more jobs"
         guard !isAwaitingResponse, isContinuationPrompt(prompt) else { return }
         if anchorUserJobQuery(excludingLatestUserMessage: prompt) == nil { return }