0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-11 07:11:32 -05:00

🐛 Fix repair for child not found situations

This commit is contained in:
Alejandro Alonso 2023-11-21 20:10:50 +01:00 committed by Andrey Antukh
parent 8325818da2
commit 37e9d9819b
2 changed files with 6 additions and 12 deletions

View file

@ -68,16 +68,10 @@
(defmethod repair-error :child-not-found
[_ {:keys [shape page-id args] :as error} file-data _]
(let [repair-shape
(fn [parent-shape]
; Remove child shape from children list
(log/debug :hint " -> Remove child " :child-id (: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)
(pcb/with-file-data file-data)
(pcb/update-shapes [(:id shape)] repair-shape))))
(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/with-file-data file-data)
(pcb/change-parent (:parent-id args) [shape] nil {:component-swap true})))
(defmethod repair-error :frame-not-found
[_ {:keys [shape page-id] :as error} file-data _]

View file

@ -126,8 +126,8 @@
(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))))))))
child file page
:parent-id (:id shape)))))))))
(defn validate-frame!
"Validate that the frame-id shape exists and is indeed a frame. Also