mirror of
https://github.com/penpot/penpot.git
synced 2026-10-02 16:56:16 +00:00
⚡ Skip builder local apply on plain translations (#12036)
Translations that touch no group-like shape or ancestor do not need the builder objects updated, since only parent resizing reads them. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
da55d6723c
commit
d531c0050b
@ -187,7 +187,8 @@
|
||||
(assert (check-changes changes)
|
||||
"expected valid changes")
|
||||
|
||||
(if-let [file-data (::file-data (meta changes))]
|
||||
(if-let [file-data (and (not (::skip-local? (meta changes)))
|
||||
(::file-data (meta changes)))]
|
||||
(let [library-data (::library-data (meta changes))
|
||||
index (::applied-changes-count (meta changes))
|
||||
redo-changes (:redo-changes changes)
|
||||
@ -206,6 +207,11 @@
|
||||
::applied-changes-count (count redo-changes)))
|
||||
changes))
|
||||
|
||||
(defn skip-local
|
||||
"Stop applying changes to the builder objects."
|
||||
[changes skip?]
|
||||
(vary-meta changes assoc ::skip-local? skip?))
|
||||
|
||||
(defn- without-changes-local
|
||||
"Append changes through `f` without applying them to the mounted page's
|
||||
working state."
|
||||
|
||||
@ -184,6 +184,26 @@
|
||||
::update-shapes-buffer-event))))
|
||||
(rx/empty)))))))
|
||||
|
||||
(defn- any-group-like?
|
||||
"Whether any of `ids` or their ancestors is group-like."
|
||||
[objects ids]
|
||||
(let [cache (js/Map.)
|
||||
group-like?
|
||||
(fn group-like? [id]
|
||||
(let [cached (.get cache id)]
|
||||
(if (some? cached)
|
||||
cached
|
||||
(let [shape (get objects id)
|
||||
parent-id (:parent-id shape)
|
||||
result (boolean
|
||||
(or (cfh/group-like-shape? shape)
|
||||
(and (some? parent-id)
|
||||
(not= parent-id id)
|
||||
(group-like? parent-id))))]
|
||||
(.set cache id result)
|
||||
result))))]
|
||||
(boolean (some group-like? ids))))
|
||||
|
||||
(defn update-shapes
|
||||
([ids update-fn]
|
||||
(update-shapes ids update-fn nil))
|
||||
@ -212,10 +232,15 @@
|
||||
objects (dsh/lookup-page-objects state page-id)
|
||||
ids (into [] (filter some?) ids)
|
||||
|
||||
;; Parent resizing only reads the builder objects for groups
|
||||
skip-local?
|
||||
(and translation? (not (any-group-like? objects ids)))
|
||||
|
||||
changes
|
||||
(-> (pcb/empty-changes it page-id)
|
||||
(pcb/set-save-undo? save-undo?)
|
||||
(pcb/set-stack-undo? stack-undo?)
|
||||
(pcb/skip-local skip-local?)
|
||||
(cls/generate-update-shapes ids
|
||||
update-fn
|
||||
objects
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user