From c42eb6ff86dbc8a0018409f85352490fb0a0f0c9 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 20 Apr 2026 16:31:56 +0200 Subject: [PATCH] :bug: Fix problem with selection performance --- frontend/src/app/render_wasm/api.cljs | 15 +------------ frontend/src/app/render_wasm/shape.cljs | 6 +----- frontend/src/app/worker/index.cljs | 28 ------------------------- 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index 0178f8afa5..ec064493e3 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -27,7 +27,6 @@ [app.main.router :as rt] [app.main.store :as st] [app.main.ui.shapes.text] - [app.main.worker :as mw] [app.render-wasm.api.fonts :as f] [app.render-wasm.api.shapes :as shapes] [app.render-wasm.api.texts :as t] @@ -1114,15 +1113,6 @@ (render-finish) (perf/end-measure "render-from-cache")) -(defn update-text-rect! - [id] - (when wasm/context-initialized? - (mw/emit! - {:cmd :index/update-text-rect - :page-id (:current-page-id @st/state) - :shape-id id - :dimensions (get-text-dimensions id)}))) - (defn- ensure-text-content "Guarantee that the shape always sends a valid text tree to WASM. When the content is nil (freshly created text) we fall back to @@ -1195,10 +1185,7 @@ "Synchronously update text layouts for all shapes and send rect updates to the worker index." [text-ids] - (run! (fn [id] - (f/update-text-layout id) - (update-text-rect! id)) - text-ids)) + (run! f/update-text-layout text-ids)) (defn process-pending [shapes thumbnails full on-complete] diff --git a/frontend/src/app/render_wasm/shape.cljs b/frontend/src/app/render_wasm/shape.cljs index 032f3d7926..ac61bbac2e 100644 --- a/frontend/src/app/render_wasm/shape.cljs +++ b/frontend/src/app/render_wasm/shape.cljs @@ -323,11 +323,7 @@ (vals) (rx/from) (rx/mapcat (fn [callback] (callback))) - (rx/reduce conj []) - (rx/tap - (fn [] - (when (cfh/text-shape? shape) - (api/update-text-rect! (:id shape))))))) + (rx/reduce conj []))) (rx/empty)))) (defn process-shape-changes! diff --git a/frontend/src/app/worker/index.cljs b/frontend/src/app/worker/index.cljs index c40f0b6fd8..3ff1f37d19 100644 --- a/frontend/src/app/worker/index.cljs +++ b/frontend/src/app/worker/index.cljs @@ -10,9 +10,7 @@ [app.common.data :as d] [app.common.data.macros :as dm] [app.common.files.changes :as ch] - [app.common.geom.matrix :as gmt] [app.common.geom.rect :as grc] - [app.common.geom.shapes :as gsh] [app.common.logging :as log] [app.common.time :as ct] [app.worker.impl :as impl] @@ -65,33 +63,7 @@ (log/dbg :hint "page index updated" :id page-id :elapsed elapsed ::log/sync? true)))) nil)) -(defmethod impl/handler :index/update-text-rect - [{:keys [page-id shape-id dimensions]}] - (let [page (dm/get-in @state [:pages-index page-id]) - objects (get page :objects) - shape (get objects shape-id) - center (gsh/shape->center shape) - transform (:transform shape (gmt/matrix)) - rect (-> (grc/make-rect dimensions) - (grc/rect->points)) - points (gsh/transform-points rect center transform) - selrect (gsh/calculate-selrect points (gsh/points->center points)) - - data {:position-data nil - :points points - :selrect selrect} - - shape (d/patch-object shape data) - - objects - (assoc objects shape-id shape)] - - (swap! state update-in [::text-rect page-id] assoc shape-id data) - (swap! state update-in [::selection page-id] selection/update-index-single objects shape) - nil)) - ;; FIXME: schema - (defmethod impl/handler :index/query-snap [{:keys [page-id frame-id axis ranges bounds] :as message}] (if-let [index (get @state ::snap)]