From 7ebf8dd70215e1f295d6f1d11cd0ac34ba47ee7d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 8 Apr 2024 17:12:27 +0200 Subject: [PATCH 1/3] :sparkles: Skip invalid graphics on migration post binfile import --- backend/src/app/binfile/common.clj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/app/binfile/common.clj b/backend/src/app/binfile/common.clj index ace98c80ec..bfbfe6186f 100644 --- a/backend/src/app/binfile/common.clj +++ b/backend/src/app/binfile/common.clj @@ -479,7 +479,9 @@ (doseq [[feature file-id] (-> *state* deref :pending-to-migrate)] (case feature "components/v2" - (feat.compv2/migrate-file! cfg file-id :validate? (::validate cfg true)) + (feat.compv2/migrate-file! cfg file-id + :validate? (::validate cfg true) + :skip-on-graphic-error? true) "fdata/shape-data-type" nil From e8b29c3cfc21cb0085f2191e917e8ce201eafb79 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 8 Apr 2024 17:13:20 +0200 Subject: [PATCH 2/3] :bug: Fix incorrect grid calcultation condition on compv2 migration script --- backend/src/app/features/components_v2.clj | 35 ++++++++++----------- common/src/app/common/types/shape_tree.cljc | 9 +++--- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/backend/src/app/features/components_v2.clj b/backend/src/app/features/components_v2.clj index 36f0a5ad55..21ed5f52ac 100644 --- a/backend/src/app/features/components_v2.clj +++ b/backend/src/app/features/components_v2.clj @@ -1600,29 +1600,28 @@ nil true)) new-shapes (volatile! []) - - add-shape (fn [shape] - (vswap! new-shapes conj shape)) + add-shape #(vswap! new-shapes conj %) fdata' (create-media-grid fdata page-id (:id frame) grid assets add-shape) - ;; When svgs had different width&height and viewport, sometimes the old graphics - ;; importer didn't calculate well the media object size. So, after migration we - ;; recalculate grid size from the actual size of the created shapes. - new-grid (ctst/generate-shape-grid @new-shapes position grid-gap) - - {new-width :width new-height :height} (meta new-grid) - - fdata'' (if-not (and (mth/close? width new-width) (mth/close? height new-height)) - (do - (l/inf :hint "fixing graphics sizes" - :file-id (str (:id fdata)) - :group group-name) - (fix-graphics-size fdata' new-grid page-id (:id frame))) - fdata')] + ;; When svgs had different width&height and viewport, + ;; sometimes the old graphics importer didn't + ;; calculate well the media object size. So, after + ;; migration we recalculate grid size from the actual + ;; size of the created shapes. + fdata' (if-let [grid (ctst/generate-shape-grid @new-shapes position grid-gap)] + (let [{new-width :width new-height :height} (meta grid)] + (if-not (and (mth/close? width new-width) (mth/close? height new-height)) + (do + (l/inf :hint "fixing graphics sizes" + :file-id (str (:id fdata)) + :group group-name) + (fix-graphics-size fdata' grid page-id (:id frame))) + fdata')) + fdata')] (recur (next groups) - fdata'' + fdata' (gpt/add position (gpt/point 0 (+ height (* 2 grid-gap) frame-gap)))))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/common/src/app/common/types/shape_tree.cljc b/common/src/app/common/types/shape_tree.cljc index 646c26641e..a76189f713 100644 --- a/common/src/app/common/types/shape_tree.cljc +++ b/common/src/app/common/types/shape_tree.cljc @@ -461,16 +461,15 @@ row-size (+ (reduce d/max ##-Inf (map :height bounds)) gap) column-size (+ (reduce d/max ##-Inf (map :width bounds)) gap) - get-next (fn get-next - [counter] + get-next (fn get-next [counter] (let [row (quot counter grid-size) column (mod counter grid-size) position (->> (gpt/point (* column column-size) (* row row-size)) (gpt/add start-position))] - (lazy-seq - (cons position (get-next (inc counter))))))] - + (cons position + (lazy-seq + (get-next (inc counter))))))] (with-meta (get-next 0) {:width (* grid-size column-size) :height (* grid-size row-size)})))) From a4c7cc51bbb67a1e8addd8eb6096ef84c922c83f Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 9 Apr 2024 12:32:18 +0200 Subject: [PATCH 3/3] :bug: Fix crash on moving a copy in a copy (for a migrated file) --- common/src/app/common/types/container.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index d713905081..ad24241440 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -509,7 +509,7 @@ (every? nil?)))] (or ;;We don't want to change the structure of component copies - (ctk/in-component-copy? parent) + (has-any-copy-parent? objects parent) ;; If we are moving something containing a main instance the container can't be part of a component (neither main nor copy) (and selected-main-instance? parent-in-component?) ;; Avoid placing a shape as a direct or indirect child of itself,