diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index 53625e1578..bc770b2c72 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -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 _ _] diff --git a/common/src/app/common/files/changes_builder.cljc b/common/src/app/common/files/changes_builder.cljc index fad2390920..77a823b76c 100644 --- a/common/src/app/common/files/changes_builder.cljc +++ b/common/src/app/common/files/changes_builder.cljc @@ -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)))) diff --git a/common/test/common_tests/files_changes_test.cljc b/common/test/common_tests/files_changes_test.cljc index 37159b2fd6..da98d1b1ef 100644 --- a/common/test/common_tests/files_changes_test.cljc +++ b/common/test/common_tests/files_changes_test.cljc @@ -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)))))) diff --git a/frontend/src/app/worker/index.cljs b/frontend/src/app/worker/index.cljs index cf28759971..4fcd9192b8 100644 --- a/frontend/src/app/worker/index.cljs +++ b/frontend/src/app/worker/index.cljs @@ -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]))