♻️ Add skip-validate-changes helper

apply-changes-local and the page index worker drop the :validate-shapes
changes with the same inline filter. Move it to
app.common.files.changes as skip-validate-changes, next to the
:validate-shapes change, so it is easy to find every place that skips
the validation if it changes in the future.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
Eva Marco 2026-10-01 11:42:23 +02:00 committed by Andrés Moya
parent 5ad391eafa
commit 7fee18dc1a
4 changed files with 15 additions and 2 deletions

View File

@ -1118,6 +1118,12 @@
;; --- Validate Shapes
(defn skip-validate-changes
"Remove the :validate-shapes changes, for data where the shapes can't
be validated (e.g. without the full file or its libraries)."
[changes]
(remove #(= :validate-shapes (:type %)) changes))
#?(:clj
(defmethod process-change :validate-shapes
[data _ _]

View File

@ -199,7 +199,7 @@
new-changes (if (< index (count redo-changes))
(->> (subvec (:redo-changes changes) index)
;; Validation only makes sense on the real file data
(remove #(= :validate-shapes (:type %)))
(cfc/skip-validate-changes)
(map #(-> %
(assoc :page-id uuid/zero)
(dissoc :component-id))))

View File

@ -1210,3 +1210,10 @@
(t/is (seq (:redo-changes changes)))
(t/is (not-any? #(= :validate-shapes (:type %)) (:redo-changes changes)))))
(t/deftest skip-validate-changes
(let [changes [{:type :mod-obj :id (uuid/next)}
{:type :validate-shapes :page-id (uuid/next) :shape-ids []}
{:type :del-obj :id (uuid/next)}]]
(t/is (= [:mod-obj :del-obj]
(map :type (ch/skip-validate-changes changes))))))

View File

@ -42,7 +42,7 @@
(let [old-page (dm/get-in @state [:pages-index page-id])
;; The index only holds pages, without the file id nor its
;; components, so shape validation can't run here
changes (remove #(= :validate-shapes (:type %)) changes)
changes (ch/skip-validate-changes changes)
new-page (-> state
(swap! ch/process-changes changes false)
(dm/get-in [:pages-index page-id]))