From 86e31e7e862ef77e9dd65c881be8cd539d918bf4 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 10 Apr 2020 16:26:19 +0200 Subject: [PATCH] :lipstick: Minor cosmetic changes on refs. --- frontend/src/uxbox/main/refs.cljs | 38 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/frontend/src/uxbox/main/refs.cljs b/frontend/src/uxbox/main/refs.cljs index 981cb315c..da885a909 100644 --- a/frontend/src/uxbox/main/refs.cljs +++ b/frontend/src/uxbox/main/refs.cljs @@ -61,25 +61,27 @@ (get-in % [:workspace-data page-id :objects]))) (l/derive st/state))) -(defn objects-by-id [ids] - (let [set-ids (set ids)] - (-> (l/lens (fn [state] - (let [page-id (get-in state [:workspace-page :id]) - objects (get-in state [:workspace-data page-id :objects])] - (mapv #(get objects %) set-ids)))) - (l/derive st/state)))) +(defn objects-by-id + [ids] + (-> (l/lens (fn [state] + (let [page-id (get-in state [:workspace-page :id]) + objects (get-in state [:workspace-data page-id :objects])] + (->> (set ids) + (map #(get objects %)) + (filter identity) + (vec))))) + (l/derive st/state))) -(defn is-child-selected? [id] - (let [is-child-selector - (fn [state] - (let [page-id (get-in state [:workspace-page :id]) - objects (get-in state [:workspace-data page-id :objects]) - selected (get-in state [:workspace-local :selected]) - shape (get objects id) - children (helpers/get-children id objects)] - (some selected children)))] - - (-> (l/lens is-child-selector) +(defn is-child-selected? + [id] + (letfn [(selector [state] + (let [page-id (get-in state [:workspace-page :id]) + objects (get-in state [:workspace-data page-id :objects]) + selected (get-in state [:workspace-local :selected]) + shape (get objects id) + children (helpers/get-children id objects)] + (some selected children)))] + (-> (l/lens selector) (l/derive st/state)))) (def selected-shapes