0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

🐛 Add validation fix for duplicated children

This commit is contained in:
Andrés Moya 2024-01-23 15:23:59 +01:00 committed by Andrey Antukh
parent d69db0b337
commit 00e894d801

View file

@ -118,9 +118,9 @@
(vswap! detached-ids conj (:id shape)))
(ctk/detach-shape shape)))
remove-missing-children
fix-bad-children
(fn [file-data]
;; Remove any child that does not exist.
;; Remove any child that does not exist. And also remove duplicated children.
(letfn [(fix-container
[container]
(d/update-when container :objects update-vals (partial fix-shape container)))
@ -130,7 +130,9 @@
(let [objects (:objects container)]
(d/update-when shape :shapes
(fn [shapes]
(d/removev #(nil? (get objects %)) shapes)))))]
(->> shapes
(d/removev #(nil? (get objects %)))
(into [] (distinct)))))))]
(-> file-data
(update :pages-index update-vals fix-container)
@ -508,7 +510,7 @@
(d/update-when :components update-vals fix-container))))]
(-> file-data
(remove-missing-children)
(fix-bad-children)
(fix-misc-shape-issues)
(fix-recent-colors)
(fix-missing-image-metadata)