mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
🐛 Fix problem with selection performance
This commit is contained in:
parent
b5701923ba
commit
c42eb6ff86
@ -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]
|
||||
|
||||
@ -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!
|
||||
|
||||
@ -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)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user