0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-03 04:49:03 -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))) (vswap! detached-ids conj (:id shape)))
(ctk/detach-shape shape))) (ctk/detach-shape shape)))
remove-missing-children fix-bad-children
(fn [file-data] (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 (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)))
@ -130,7 +130,9 @@
(let [objects (:objects container)] (let [objects (:objects container)]
(d/update-when shape :shapes (d/update-when shape :shapes
(fn [shapes] (fn [shapes]
(d/removev #(nil? (get objects %)) shapes)))))] (->> shapes
(d/removev #(nil? (get objects %)))
(into [] (distinct)))))))]
(-> file-data (-> file-data
(update :pages-index update-vals fix-container) (update :pages-index update-vals fix-container)
@ -508,7 +510,7 @@
(d/update-when :components update-vals fix-container))))] (d/update-when :components update-vals fix-container))))]
(-> file-data (-> file-data
(remove-missing-children) (fix-bad-children)
(fix-misc-shape-issues) (fix-misc-shape-issues)
(fix-recent-colors) (fix-recent-colors)
(fix-missing-image-metadata) (fix-missing-image-metadata)