Quellcode durchsuchen

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 vor 3 Wochen
Ursprung
Commit
b4cc5e5fad
1 geänderte Dateien mit 16 neuen und 9 gelöschten Zeilen
  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
454 454
         }
455 455
     }
456 456
 
457
+    /// Returns `false` and presents the paywall when the user does not have an active Pro subscription.
458
+    @discardableResult
459
+    private func ensureProAccess() -> Bool {
460
+        guard SubscriptionStore.shared.isProActive else {
461
+            presentPremiumPlansSheet()
462
+            return false
463
+        }
464
+        return true
465
+    }
466
+
457 467
     private func presentPremiumPlansSheet() {
458 468
         guard let hostWindow = window else { return }
459 469
 
@@ -1346,7 +1356,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1346 1356
         ])
1347 1357
 
1348 1358
         cvMakerPageView.onContinueToProfileSelection = { [weak self] template in
1349
-            guard let self else { return }
1359
+            guard let self, self.ensureProAccess() else { return }
1350 1360
             self.pendingCVTemplate = template
1351 1361
             self.profilesListPageView.setPendingCVTemplateDisplayName(template.name)
1352 1362
             self.selectProfileSidebarForCVMakerFlow()
@@ -1420,6 +1430,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1420 1430
     }
1421 1431
 
1422 1432
     private func presentCVDocumentPreview(profile: SavedProfile, template: CVTemplate) {
1433
+        guard ensureProAccess() else { return }
1423 1434
         isCVDocumentPreviewPresented = true
1424 1435
         cvFilledPreviewPageView.configure(profile: profile, template: template)
1425 1436
         cvFilledPreviewPageView.isHidden = false
@@ -1436,6 +1447,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1436 1447
     }
1437 1448
 
1438 1449
     private func presentProfileEditor(existingID: UUID?) {
1450
+        guard ensureProAccess() else { return }
1439 1451
         if isCVDocumentPreviewPresented {
1440 1452
             dismissCVDocumentPreview()
1441 1453
         }
@@ -1772,10 +1784,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1772 1784
     }
1773 1785
 
1774 1786
     @objc private func didSubmitSearch() {
1775
-        guard SubscriptionStore.shared.isProActive else {
1776
-            presentPremiumPlansSheet()
1777
-            return
1778
-        }
1787
+        guard ensureProAccess() else { return }
1779 1788
         let prompt = jobKeywordsField.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
1780 1789
         guard !prompt.isEmpty, !isAwaitingResponse else { return }
1781 1790
         let isContinuation = isContinuationPrompt(prompt)
@@ -1892,6 +1901,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1892 1901
     }
1893 1902
 
1894 1903
     private func focusSearchField(seed: String) {
1904
+        guard ensureProAccess() else { return }
1895 1905
         jobKeywordsField.stringValue = seed
1896 1906
         window?.makeFirstResponder(jobKeywordsField)
1897 1907
         if let editor = jobKeywordsField.window?.fieldEditor(true, for: jobKeywordsField) as? NSTextView {
@@ -1900,10 +1910,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1900 1910
     }
1901 1911
 
1902 1912
     @objc private func didTapLoadMoreJobs() {
1903
-        guard SubscriptionStore.shared.isProActive else {
1904
-            presentPremiumPlansSheet()
1905
-            return
1906
-        }
1913
+        guard ensureProAccess() else { return }
1907 1914
         let prompt = "Show more jobs"
1908 1915
         guard !isAwaitingResponse, isContinuationPrompt(prompt) else { return }
1909 1916
         if anchorUserJobQuery(excludingLatestUserMessage: prompt) == nil { return }