From 6812099900b6106da109a33edd8c786f8963d3c1 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 22 Dec 2021 18:37:08 +0100 Subject: [PATCH] :sparkles: Simplify frames selection mechanism. --- common/src/app/common/pages/helpers.cljc | 20 ++++++-------------- frontend/src/app/main/refs.cljs | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/common/src/app/common/pages/helpers.cljc b/common/src/app/common/pages/helpers.cljc index 29d821a281..5bc912c752 100644 --- a/common/src/app/common/pages/helpers.cljc +++ b/common/src/app/common/pages/helpers.cljc @@ -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 diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index adc3cfaf60..efaaddaa93 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -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))