diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-28 10:08:10 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-28 10:08:10 -0500 |
| commit | fc57dcac9a7c972fa59dbd0aded06ae0725000ca (patch) | |
| tree | ca61f78411bb8ce23c332a70a821642a21e44998 /pearl.el | |
| parent | 2d9c27caa08b231983543c0a4be691d7926980d8 (diff) | |
| download | pearl-fc57dcac9a7c972fa59dbd0aded06ae0725000ca.tar.gz pearl-fc57dcac9a7c972fa59dbd0aded06ae0725000ca.zip | |
refactor(view-sync): pearl--save-query-mark-synced preserves unknown plist keys
The prior implementation rebuilt the spec from a fixed key set (:filter, :sort, :order, plus the four :linear-view-* sync keys and the optional :linear-view-url) and silently dropped anything else. No keys outside that set live on a saved-query entry today, but the persistence layer was coupled to the current schema. A future :description, a user-added annotation, or any new pearl field would vanish on every re-sync.
I switched to copy-then-plist-put: shallow-copy the existing spec, plist-put the four sync keys on top, and conditionally plist-put :linear-view-url when this call provided one. Arbitrary keys survive untouched. The URL-preservation behavior on a re-sync that omits view-url is unchanged: the prior :linear-view-url is already in the copied spec, so the when-view-url guard skips the put and leaves it in place.
I added one regression test that seeds an entry with :description and :user-tag alongside the standard keys and asserts all of them survive a mark-synced call. All 661 ert tests pass. make compile and make lint are clean.
Diffstat (limited to 'pearl.el')
| -rw-r--r-- | pearl.el | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -3820,22 +3820,22 @@ isn't in `pearl-saved-queries'." (let ((entry (assoc name pearl-saved-queries))) (unless entry (user-error "No saved query named %s" name)) - (let* ((spec (cdr entry)) - (filter (plist-get spec :filter)) - (sort (plist-get spec :sort)) - (order (plist-get spec :order)) - (existing-url (plist-get spec :linear-view-url)) - (effective-url (or view-url existing-url)) - (synced-at (format-time-string "%Y-%m-%dT%H:%M:%SZ" nil t)) - (new-spec (append (list :filter filter) - (when sort (list :sort sort)) - (when order (list :order order)) - (list :linear-view-id view-id - :linear-view-team-id team-id - :linear-view-shared shared - :linear-view-synced-at synced-at) - (when effective-url - (list :linear-view-url effective-url))))) + ;; Copy the existing spec and plist-put each sync key on top. Earlier + ;; versions rebuilt the spec from `:filter', `:sort', `:order' + the four + ;; sync keys, which silently dropped any other key on the entry -- a + ;; future `:description', a user-added annotation, or any new schema + ;; field would vanish on every re-sync. Copy-then-put preserves + ;; everything the user (or future pearl code) attached. + (let* ((synced-at (format-time-string "%Y-%m-%dT%H:%M:%SZ" nil t)) + (new-spec (copy-sequence (cdr entry)))) + (setq new-spec (plist-put new-spec :linear-view-id view-id)) + (setq new-spec (plist-put new-spec :linear-view-team-id team-id)) + (setq new-spec (plist-put new-spec :linear-view-shared shared)) + (setq new-spec (plist-put new-spec :linear-view-synced-at synced-at)) + ;; Only touch :linear-view-url when this call supplied one; a re-sync + ;; whose API response somehow lacks the URL must not erase the prior. + (when view-url + (setq new-spec (plist-put new-spec :linear-view-url view-url))) (setq pearl-saved-queries (cons (cons name new-spec) (assoc-delete-all name (copy-sequence pearl-saved-queries)))) |
