From 90532b760a97a4685d76b59b5938d339d5016ad3 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 23 Jun 2022 13:24:03 +0200 Subject: [PATCH] :zap: Improved performance when rendering paths --- .../src/app/main/ui/workspace/shapes/path.cljs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/shapes/path.cljs b/frontend/src/app/main/ui/workspace/shapes/path.cljs index dee228b39..58e1ead3d 100644 --- a/frontend/src/app/main/ui/workspace/shapes/path.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/path.cljs @@ -14,6 +14,12 @@ [app.main.ui.workspace.shapes.path.common :as pc] [rumext.alpha :as mf])) +(defn apply-content-modifiers + [shape content-modifiers] + (let [shape (update shape :content upc/apply-content-modifiers content-modifiers) + [_ new-selrect] (helpers/content->points+selrect shape (:content shape))] + (assoc shape :selrect new-selrect))) + (mf/defc path-wrapper {::mf/wrap-props false} [props] @@ -22,11 +28,13 @@ content-modifiers (mf/deref content-modifiers-ref) editing-id (mf/deref refs/selected-edition) editing? (= editing-id (:id shape)) - shape (update shape :content upc/apply-content-modifiers content-modifiers) - [_ new-selrect] - (helpers/content->points+selrect shape (:content shape)) - shape (assoc shape :selrect new-selrect)] + shape + (mf/use-memo + (mf/deps shape content-modifiers) + #(cond-> shape + (some? content-modifiers) + (apply-content-modifiers content-modifiers)))] [:> shape-container {:shape shape :pointer-events (when editing? "none")}