mirror of
https://github.com/penpot/penpot.git
synced 2026-11-28 22:20:34 +00:00
♻️ Use if instead of or and when in builder fallbacks
prepare-restore-component and generate-delete-shapes fall back to other data when the changes builder has no library data, objects or page. Use an if on the has-*? check instead of (or (when ...) ...), which is easier to read. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
65dfeb3d87
commit
56ec15e317
@ -490,13 +490,13 @@
|
|||||||
(prepare-restore-component changes library-data component-id page nil nil nil nil)))
|
(prepare-restore-component changes library-data component-id page nil nil nil nil)))
|
||||||
|
|
||||||
([changes library-data component-id page position old-id parent-id frame-id]
|
([changes library-data component-id page position old-id parent-id frame-id]
|
||||||
(let [library-data (or (when (pcb/has-library-data? changes)
|
(let [library-data (if (pcb/has-library-data? changes)
|
||||||
(pcb/get-library-data changes))
|
(pcb/get-library-data changes)
|
||||||
library-data)
|
library-data)
|
||||||
component (ctkl/get-deleted-component library-data component-id)
|
component (ctkl/get-deleted-component library-data component-id)
|
||||||
objects (or (when (pcb/has-objects? changes)
|
objects (if (pcb/has-objects? changes)
|
||||||
(pcb/get-objects changes))
|
(pcb/get-objects changes)
|
||||||
(:objects page))
|
(:objects page))
|
||||||
parent (get objects parent-id)
|
parent (get objects parent-id)
|
||||||
main-inst (get-in component [:objects (:main-instance-id component)])
|
main-inst (get-in component [:objects (:main-instance-id component)])
|
||||||
inside-component? (some? (ctn/get-instance-root (:objects page) parent))
|
inside-component? (some? (ctn/get-instance-root (:objects page) parent))
|
||||||
|
|||||||
@ -270,9 +270,9 @@
|
|||||||
(let [objects (pcb/get-objects changes)
|
(let [objects (pcb/get-objects changes)
|
||||||
data (pcb/get-library-data changes)
|
data (pcb/get-library-data changes)
|
||||||
page-id (pcb/get-page-id changes)
|
page-id (pcb/get-page-id changes)
|
||||||
page (or (when (pcb/has-page? changes)
|
page (if (pcb/has-page? changes)
|
||||||
(pcb/get-page changes))
|
(pcb/get-page changes)
|
||||||
(ctpl/get-page data page-id))
|
(ctpl/get-page data page-id))
|
||||||
ids (cfh/clean-loops objects ids)
|
ids (cfh/clean-loops objects ids)
|
||||||
|
|
||||||
in-component-copy?
|
in-component-copy?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user