mirror of
https://github.com/penpot/penpot.git
synced 2025-06-19 18:51:38 +02:00
⚡ Add minor optimizations to workspace shapes/group ns
This commit is contained in:
parent
469de48af2
commit
cef74377df
1 changed files with 9 additions and 16 deletions
|
@ -6,33 +6,26 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.shapes.group
|
(ns app.main.ui.workspace.shapes.group
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.workspace :as dw]
|
[app.common.data.macros :as dm]
|
||||||
[app.main.refs :as refs]
|
[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.group :as group]
|
||||||
[app.main.ui.shapes.shape :refer [shape-container]]
|
[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]))
|
[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
|
(defn group-wrapper-factory
|
||||||
[shape-wrapper]
|
[shape-wrapper]
|
||||||
(let [group-shape (group/group-shape shape-wrapper)]
|
(let [group-shape (group/group-shape shape-wrapper)]
|
||||||
(mf/fnc group-wrapper
|
(mf/fnc group-wrapper
|
||||||
{::mf/wrap [#(mf/memo' % (mf/check-props ["shape"]))]
|
{::mf/wrap [#(mf/memo' % check-shape-props)]
|
||||||
::mf/wrap-props false}
|
::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
childs-ref (mf/use-memo (mf/deps (:id shape)) #(refs/children-objects (:id shape)))
|
shape-id (dm/get-prop shape :id)
|
||||||
childs (mf/deref childs-ref)]
|
|
||||||
|
childs* (mf/with-memo [shape-id]
|
||||||
|
(refs/children-objects shape-id))
|
||||||
|
childs (mf/deref childs*)]
|
||||||
|
|
||||||
[:> shape-container {:shape shape}
|
[:> shape-container {:shape shape}
|
||||||
[:& group-shape
|
[:& group-shape
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue