mirror of
https://github.com/penpot/penpot.git
synced 2025-02-09 08:38:15 -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]
|
(fn [parent-shape]
|
||||||
; Remove child shape from children list
|
; Remove child shape from children list
|
||||||
(log/debug :hint " -> Remove child " :child-id (:child-id args))
|
(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)
|
(log/info :hint "Repairing shape :child-not-found" :id (:id shape) :name (:name shape) :page-id page-id)
|
||||||
(-> (pcb/empty-changes nil page-id)
|
(-> (pcb/empty-changes nil page-id)
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
(def ^:dynamic *errors* nil)
|
(def ^:dynamic *errors* nil)
|
||||||
|
|
||||||
(defn report-error!
|
(defn report-error!
|
||||||
[code hint shape file page & args]
|
[code hint shape file page & {:as args}]
|
||||||
(if (some? *errors*)
|
(if (some? *errors*)
|
||||||
(vswap! *errors* conj {:code code
|
(vswap! *errors* conj {:code code
|
||||||
:hint hint
|
:hint hint
|
||||||
|
@ -122,11 +122,12 @@
|
||||||
shape file page)))
|
shape file page)))
|
||||||
|
|
||||||
(doseq [child-id (:shapes shape)]
|
(doseq [child-id (:shapes shape)]
|
||||||
(when (nil? (ctst/get-shape page child-id))
|
(let [child (ctst/get-shape page child-id)]
|
||||||
(report-error! :child-not-found
|
(when (or (nil? child) (not= (:parent-id child) (:id shape)))
|
||||||
(str/ffmt "Child % not found" child-id)
|
(report-error! :child-not-found
|
||||||
shape file page
|
(str/ffmt "Child % not found" child-id)
|
||||||
:child-id child-id)))))))
|
shape file page
|
||||||
|
:child-id child-id))))))))
|
||||||
|
|
||||||
(defn validate-frame!
|
(defn validate-frame!
|
||||||
"Validate that the frame-id shape exists and is indeed a frame. Also
|
"Validate that the frame-id shape exists and is indeed a frame. Also
|
||||||
|
|
Loading…
Add table
Reference in a new issue