0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-10 14:51:37 -05:00

Add minor perf improvement on components-v2 migration

This commit is contained in:
Andrey Antukh 2023-05-19 19:50:45 +02:00 committed by Alejandro Alonso
parent 0078c0e601
commit 68c0b0e8a7

View file

@ -326,12 +326,13 @@
main instances for all components there and remove shapes from library components.
Mark the file with the :components-v2 option."
[file-data]
(let [migrated? (dm/get-in file-data [:options :components-v2])]
(if migrated?
file-data
(let [components (ctkl/components-seq file-data)]
(if (or (empty? components)
(dm/get-in file-data [:options :components-v2]))
(if (empty? components)
(assoc-in file-data [:options :components-v2] true)
(let [grid-gap 50
[file-data page-id start-pos]
(get-or-add-library-page file-data grid-gap)
@ -392,10 +393,9 @@
root-to-board
(fn [shape]
(cond-> shape
(and (ctk/instance-head? shape)
(not= (:type shape) :frame))
(assoc :type :frame
:fills []
(and (ctk/instance-root? shape)
(cph/frame-shape? shape))
(assoc :fills []
:hide-in-viewer true
:rx 0
:ry 0)))
@ -407,7 +407,7 @@
(-> file-data
(add-instance-grid (sort-by :name components))
(update :pages-index update-vals roots-to-board)
(assoc-in [:options :components-v2] true))))))
(assoc-in [:options :components-v2] true))))))))
(defn- absorb-components
[file-data used-components library-data]