Skip to content

Commit

Permalink
Merge pull request penpot#3832 from penpot/superalex-fix-child-not-found
Browse files Browse the repository at this point in the history
🐛 Fix repair for child not found situations
  • Loading branch information
niwinz authored Nov 21, 2023
2 parents d12b6eb + 406303b commit 65aeda1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
14 changes: 4 additions & 10 deletions common/src/app/common/files/repair.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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 _]
Expand Down
4 changes: 2 additions & 2 deletions common/src/app/common/files/validate.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 65aeda1

Please sign in to comment.