aboutsummaryrefslogtreecommitdiff
path: root/pearl.el
diff options
context:
space:
mode:
Diffstat (limited to 'pearl.el')
-rw-r--r--pearl.el63
1 files changed, 36 insertions, 27 deletions
diff --git a/pearl.el b/pearl.el
index 39b7878..ad88d4d 100644
--- a/pearl.el
+++ b/pearl.el
@@ -3953,32 +3953,41 @@ the user can re-sync with Replace to reconcile."
;; silently flip a personal view to team-shared.
(existing-shared (eq (plist-get spec :linear-view-shared) t))
(filter-data (pearl--build-issue-filter filter-plist))
- (target-name name)
- (scope (if existing-view-id
- ;; Re-sync uses the stored scope.
- (list :team-id existing-team-id
- :team-name (or (and existing-team-id
- (cdr (assoc 'name
- (seq-find
- (lambda (tm)
- (equal existing-team-id
- (cdr (assoc 'id tm))))
- (pearl--all-teams)))))
- "Personal")
- :shared existing-shared)
- (pearl--sync-saved-query-pick-scope filter-plist))))
- (unless scope
- (user-error "Cancelled; no saved query synced"))
- ;; Validate the filter at the boundary so a malformed entry surfaces
- ;; before the API call.
- (pearl--validate-issue-filter filter-plist)
- (let* ((team-id (plist-get scope :team-id))
- (shared (plist-get scope :shared))
- (scope-label (car (rassoc scope
- (pearl--sync-scope-candidates
- (pearl--all-teams)
- (plist-get filter-plist :team))))))
- (cond
+ (target-name name))
+ ;; Linear's CustomViewCreateInput.filterData expects a JSON object. An
+ ;; empty filter plist compiles to nil, which JSON-encodes as `null' and
+ ;; the API rejects with an opaque error. Refuse early -- before we
+ ;; prompt the user for scope -- so they see what's wrong instead of
+ ;; clicking through the scope picker only to hit "Linear refused".
+ (unless filter-data
+ (user-error
+ "Saved query %s has no filter constraints; Linear views need at least one constraint -- add one and re-sync"
+ name))
+ (let ((scope (if existing-view-id
+ ;; Re-sync uses the stored scope.
+ (list :team-id existing-team-id
+ :team-name (or (and existing-team-id
+ (cdr (assoc 'name
+ (seq-find
+ (lambda (tm)
+ (equal existing-team-id
+ (cdr (assoc 'id tm))))
+ (pearl--all-teams)))))
+ "Personal")
+ :shared existing-shared)
+ (pearl--sync-saved-query-pick-scope filter-plist))))
+ (unless scope
+ (user-error "Cancelled; no saved query synced"))
+ ;; Validate the filter at the boundary so a malformed entry surfaces
+ ;; before the API call.
+ (pearl--validate-issue-filter filter-plist)
+ (let* ((team-id (plist-get scope :team-id))
+ (shared (plist-get scope :shared))
+ (scope-label (car (rassoc scope
+ (pearl--sync-scope-candidates
+ (pearl--all-teams)
+ (plist-get filter-plist :team))))))
+ (cond
;; First-time sync: check for a same-name collision in the chosen
;; scope and either update-by-id (Replace), re-prompt (Rename), or
;; bail (Cancel).
@@ -4011,7 +4020,7 @@ the user can re-sync with Replace to reconcile."
;; the existing view directly).
(t
(pearl--sync-saved-query-do-update
- name existing-view-id team-id shared filter-data scope-label)))))))
+ name existing-view-id team-id shared filter-data scope-label))))))))
(defun pearl--sync-saved-query-do-create (name target-name team-id shared
filter-data scope-label)