From 9b2315d39d9a5e659628910876ef9193779a953f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 16 Jan 2025 13:20:00 +0100 Subject: [PATCH] :zap: Remove props conversion overhead on shape-options component With using new rumext call convention with :> handler and * on the component name. --- .../main/ui/workspace/sidebar/options.cljs | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options.cljs b/frontend/src/app/main/ui/workspace/sidebar/options.cljs index f8fd19e1a2..719587374f 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options.cljs @@ -42,14 +42,19 @@ ;; --- Options -(mf/defc shape-options +(mf/defc shape-options* {::mf/wrap [#(mf/throttle % 60)]} [{:keys [shape shapes-with-children page-id file-id shared-libs]}] - (let [workspace-modifiers (mf/deref refs/workspace-modifiers) - modifiers (get-in workspace-modifiers [(:id shape) :modifiers]) - shape (gsh/transform-shape shape modifiers)] + (let [shape-type (dm/get-prop shape :type) + shape-id (dm/get-prop shape :id) + + modifiers (mf/deref refs/workspace-modifiers) + modifiers (dm/get-in modifiers [shape-id :modifiers]) + + shape (gsh/transform-shape shape modifiers)] + [:* - (case (:type shape) + (case shape-type :frame [:& frame/options {:shape shape :shape-with-children shapes-with-children :file-id file-id :shared-libs shared-libs}] :group [:& group/options {:shape shape :shape-with-children shapes-with-children :file-id file-id :shared-libs shared-libs}] :text [:& text/options {:shape shape :file-id file-id :shared-libs shared-libs}] @@ -73,7 +78,7 @@ (when (= (:type panel) :component-swap) [:& component-menu {:shapes (:shapes panel) :swap-opened? true}])) -(mf/defc design-menu +(mf/defc design-menu* {::mf/wrap [mf/memo]} [{:keys [selected objects page-id file-id selected-shapes shapes-with-children]}] (let [sp-panel (mf/deref refs/specialized-panel) @@ -104,7 +109,7 @@ [:& specialized-panel {:panel sp-panel}] (d/not-empty? drawing) - [:& shape-options + [:> shape-options* {:shape (:object drawing) :page-id page-id :file-id file-id @@ -114,7 +119,7 @@ [:& page/options] (= 1 (count selected)) - [:& shape-options + [:> shape-options* {:shape (first selected-shapes) :page-id page-id :file-id file-id @@ -151,12 +156,13 @@ (st/emit! :interrupt (dwc/set-workspace-read-only false))))) design-content - (mf/html [:& design-menu {:selected selected - :objects objects - :page-id page-id - :file-id file-id - :selected-shapes selected-shapes - :shapes-with-children shapes-with-children}]) + (mf/html [:> design-menu* + {:selected selected + :objects objects + :page-id page-id + :file-id file-id + :selected-shapes selected-shapes + :shapes-with-children shapes-with-children}]) inspect-content (mf/html [:div {:class (stl/css :element-options :inspect-options)}