mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
🐛 Fix validate and repair for orphan shapes
This commit is contained in:
parent
411499942c
commit
708c615c12
2 changed files with 8 additions and 7 deletions
|
@ -72,7 +72,7 @@
|
|||
(fn [parent-shape]
|
||||
; Remove child shape from children list
|
||||
(log/debug :hint " -> Remove child " :child-id (:child-id args))
|
||||
(update parent-shape :shapes d/removev #(= % (:child-id args))))]
|
||||
(update parent-shape :shapes (partial d/removev #(= % (:child-id args)))))]
|
||||
|
||||
(log/info :hint "Repairing shape :child-not-found" :id (:id shape) :name (:name shape) :page-id page-id)
|
||||
(-> (pcb/empty-changes nil page-id)
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
(def ^:dynamic *errors* nil)
|
||||
|
||||
(defn report-error!
|
||||
[code hint shape file page & args]
|
||||
[code hint shape file page & {:as args}]
|
||||
(if (some? *errors*)
|
||||
(vswap! *errors* conj {:code code
|
||||
:hint hint
|
||||
|
@ -122,11 +122,12 @@
|
|||
shape file page)))
|
||||
|
||||
(doseq [child-id (:shapes shape)]
|
||||
(when (nil? (ctst/get-shape page child-id))
|
||||
(report-error! :child-not-found
|
||||
(str/ffmt "Child % not found" child-id)
|
||||
shape file page
|
||||
:child-id child-id)))))))
|
||||
(let [child (ctst/get-shape page child-id)]
|
||||
(when (or (nil? child) (not= (:parent-id child) (:id shape)))
|
||||
(report-error! :child-not-found
|
||||
(str/ffmt "Child % not found" child-id)
|
||||
shape file page
|
||||
:child-id child-id))))))))
|
||||
|
||||
(defn validate-frame!
|
||||
"Validate that the frame-id shape exists and is indeed a frame. Also
|
||||
|
|
Loading…
Add table
Reference in a new issue