0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-15 17:21:17 -05:00

Simplify frames selection mechanism.

This commit is contained in:
Andrey Antukh 2021-12-22 18:37:08 +01:00
parent 53e6d7ef2a
commit 6812099900
2 changed files with 7 additions and 15 deletions

View file

@ -256,20 +256,12 @@
(defn select-frames
[objects]
(let [root (get objects uuid/zero)
loopfn (fn loopfn [ids]
(let [id (first ids)
obj (get objects id)]
(cond
(or (nil? id) (nil? obj))
nil
(= :frame (:type obj))
(lazy-seq (cons obj (loopfn (rest ids))))
:else
(lazy-seq (loopfn (rest ids))))))]
(loopfn (:shapes root))))
(let [lookup #(get objects %)
frame? #(= :frame (:type %))
xform (comp (map lookup)
(filter frame?))]
(->> (:shapes (lookup uuid/zero))
(into [] xform))))
(defn clone-object
"Gets a copy of the object and all its children, with new ids

View file

@ -219,7 +219,7 @@
(l/derived :options workspace-page))
(def workspace-frames
(l/derived cp/select-frames workspace-page-objects))
(l/derived cp/select-frames workspace-page-objects =))
(def workspace-editor
(l/derived :workspace-editor st/state))