From 5baa9e8fb6645faefa55f3cc661843332d1671bf Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Mon, 29 Jan 2024 16:18:13 +0100 Subject: [PATCH] :bug: Fix shape should not be component root migration error --- backend/src/app/features/components_v2.clj | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/backend/src/app/features/components_v2.clj b/backend/src/app/features/components_v2.clj index e90e97793..9f1f38191 100644 --- a/backend/src/app/features/components_v2.clj +++ b/backend/src/app/features/components_v2.clj @@ -701,7 +701,25 @@ :component-root)))] (-> file-data (update :pages-index update-vals fix-container) - (d/update-when :components update-vals fix-container))))] + (d/update-when :components update-vals fix-container)))) + + fix-component-root-without-component + (fn [file-data] + ;; Ensure that parent-id and frame-id are not nil + (letfn [(fix-container [container] + (d/update-when container :objects update-vals fix-shape)) + + (fix-shape [shape] + (cond-> shape + (and (ctk/instance-root? shape) + (or (not (ctk/instance-head? shape)) + (not (some? (:component-file shape))))) + (dissoc shape + :component-id + :component-file + :component-root)))] + (-> file-data + (update :pages-index update-vals fix-container))))] (-> file-data (fix-file-data) @@ -726,6 +744,7 @@ (fix-frame-ids) (fix-component-nil-objects) (fix-false-copies) + (fix-component-root-without-component) (fix-copies-of-detached)))) ; <- Do not add fixes after this one ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;