From dcd53183a8471dbf457199f18d92fbd03545ac23 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 20 Jan 2022 17:15:37 +0100 Subject: [PATCH] :paperclip: Simplify distribute-objects fn impl. --- frontend/src/app/main/data/workspace.cljs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index d11e75f37..f90d696c9 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1198,15 +1198,16 @@ (ptk/reify ::distribute-objects ptk/WatchEvent (watch [_ state _] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id) - selected (wsh/lookup-selected state) - moved (-> (map #(get objects %) selected) - (gal/distribute-space axis objects)) + (let [page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id) + selected (wsh/lookup-selected state) + moved (-> (map #(get objects %) selected) + (gal/distribute-space axis objects)) - moved-objects (->> moved (group-by :id)) - ids (keys moved-objects) - update-fn (fn [shape] (first (get moved-objects (:id shape))))] + moved (d/index-by :id moved) + ids (keys moved) + + update-fn #(get moved (:id %))] (when (can-distribute? selected) (rx/of (dch/update-shapes ids update-fn {:reg-objects? true})))))))