0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-14 07:51:35 -05:00

Add minor optimizations to workspace shapes/group ns

This commit is contained in:
Andrey Antukh 2023-09-06 15:37:45 +02:00
parent 469de48af2
commit cef74377df

View file

@ -6,33 +6,26 @@
(ns app.main.ui.workspace.shapes.group
(:require
[app.main.data.workspace :as dw]
[app.common.data.macros :as dm]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.streams :as ms]
[app.main.ui.shapes.group :as group]
[app.main.ui.shapes.shape :refer [shape-container]]
[app.util.dom :as dom]
[app.main.ui.workspace.shapes.common :refer [check-shape-props]]
[rumext.v2 :as mf]))
(defn use-double-click [{:keys [id]}]
(mf/use-callback
(mf/deps id)
(fn [event]
(dom/stop-propagation event)
(dom/prevent-default event)
(st/emit! (dw/select-inside-group id @ms/mouse-position)))))
(defn group-wrapper-factory
[shape-wrapper]
(let [group-shape (group/group-shape shape-wrapper)]
(mf/fnc group-wrapper
{::mf/wrap [#(mf/memo' % (mf/check-props ["shape"]))]
{::mf/wrap [#(mf/memo' % check-shape-props)]
::mf/wrap-props false}
[props]
(let [shape (unchecked-get props "shape")
childs-ref (mf/use-memo (mf/deps (:id shape)) #(refs/children-objects (:id shape)))
childs (mf/deref childs-ref)]
(let [shape (unchecked-get props "shape")
shape-id (dm/get-prop shape :id)
childs* (mf/with-memo [shape-id]
(refs/children-objects shape-id))
childs (mf/deref childs*)]
[:> shape-container {:shape shape}
[:& group-shape