🐛 Add validation fix for false non root copies

This commit is contained in:
Andrés Moya 2024-01-24 15:59:39 +01:00 committed by Andrey Antukh
parent cceb35b053
commit 17a208d67b

View file

@ -486,15 +486,18 @@
fix-false-copies fix-false-copies
(fn [file-data] (fn [file-data]
;; Find component heads that are not main-instance but have not :shape-ref. ;; Find component heads that are not main-instance but have not :shape-ref.
;; Also shapes that have :shape-ref but are not in a copy.
(letfn [(fix-container (letfn [(fix-container
[container] [container]
(d/update-when container :objects update-vals (partial fix-shape container))) (d/update-when container :objects update-vals (partial fix-shape container)))
(fix-shape (fix-shape
[container shape] [container shape]
(if (and (ctk/instance-head? shape) (if (or (and (ctk/instance-head? shape)
(not (ctk/main-instance? shape)) (not (ctk/main-instance? shape))
(not (ctk/in-component-copy? shape))) (not (ctk/in-component-copy? shape)))
(and (ctk/in-component-copy? shape)
(nil? (ctn/get-head-shape (:objects container) shape {:allow-main? true}))))
(detach-shape container shape) (detach-shape container shape)
shape))] shape))]
(-> file-data (-> file-data