From bf719b587f3e6dbbe2efe000d5fe6d51d0de675a Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 25 Jun 2025 19:17:58 +0200 Subject: [PATCH] :sparkles: Add better shadow cleaning migration --- common/src/app/common/files/migrations.cljc | 45 ++++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 11a99507fb..96352618ba 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -1337,32 +1337,37 @@ (update :pages-index d/update-vals update-container) (d/update-when :components d/update-vals update-container)))) -(defmethod migrate-data "0004-clean-shadow-and-colors" +(defmethod migrate-data "0004-clean-shadow-color" [data _] - (letfn [(clean-shadow [shadow] - (update shadow :color (fn [color] - (let [ref-id (get color :id) - ref-file (get color :file-id)] - (-> (d/without-qualified color) - (select-keys [:opacity :color :gradient :image :ref-id :ref-file]) - (cond-> ref-id - (assoc :ref-id ref-id)) - (cond-> ref-file - (assoc :ref-file ref-file))))))) + (let [decode-color (sm/decoder types.color/schema:color sm/json-transformer) - (update-object [object] - (d/update-when object :shadow #(mapv clean-shadow %))) + clean-shadow-color + (fn [color] + (let [ref-id (get color :id) + ref-file (get color :file-id)] + (-> (d/without-qualified color) + (select-keys [:opacity :color :gradient :image :ref-id :ref-file]) + (cond-> ref-id + (assoc :ref-id ref-id)) + (cond-> ref-file + (assoc :ref-file ref-file)) + (decode-color)))) - (update-container [container] - (d/update-when container :objects d/update-vals update-object)) + clean-shadow + (fn [shadow] + (update shadow :color clean-shadow-color)) - (clean-library-color [color] - (dissoc color :file-id))] + update-object + (fn [object] + (d/update-when object :shadow #(mapv clean-shadow %))) + + update-container + (fn [container] + (d/update-when container :objects d/update-vals update-object))] (-> data (update :pages-index d/update-vals update-container) - (d/update-when :components d/update-vals update-container) - (d/update-when :colors d/update-vals clean-library-color)))) + (d/update-when :components d/update-vals update-container)))) (defmethod migrate-data "0005-deprecate-image-type" [data _] @@ -1554,7 +1559,7 @@ "0002-clean-shape-interactions" "0003-fix-root-shape" "0003-convert-path-content" - "0004-clean-shadow-and-colors" + "0004-clean-shadow-color" "0005-deprecate-image-type" "0006-fix-old-texts-fills" "0007-clear-invalid-strokes-and-fills-v2"