mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 19:16:13 +02:00
🐛 Launch component sync when adding or removing shapes
This commit is contained in:
parent
36b016a37b
commit
19ea85d9cc
2 changed files with 38 additions and 6 deletions
|
@ -871,7 +871,10 @@
|
|||
workspace-data-s
|
||||
(->> (rx/concat
|
||||
(rx/of nil)
|
||||
(rx/from-atom refs/workspace-data {:emit-current-value? true})))
|
||||
(rx/from-atom refs/workspace-data {:emit-current-value? true}))
|
||||
;; Need to get the file data before the change, so deleted shapes
|
||||
;; still exist, for example
|
||||
(rx/buffer 3 1))
|
||||
|
||||
change-s
|
||||
(->> stream
|
||||
|
@ -880,16 +883,16 @@
|
|||
(rx/observe-on :async))
|
||||
|
||||
check-changes
|
||||
(fn [[event data]]
|
||||
(fn [[event [old-data _mid_data _new-data]]]
|
||||
(let [{:keys [changes save-undo? undo-group]} (deref event)
|
||||
components-changed (reduce #(into %1 (ch/components-changed data %2))
|
||||
components-changed (reduce #(into %1 (ch/components-changed old-data %2))
|
||||
#{}
|
||||
changes)]
|
||||
(when (and (d/not-empty? components-changed) save-undo?)
|
||||
(log/info :msg "DETECTED COMPONENTS CHANGED"
|
||||
:ids (map str components-changed))
|
||||
(run! st/emit!
|
||||
(map #(update-component-sync % (:id data) undo-group)
|
||||
(map #(update-component-sync % (:id old-data) undo-group)
|
||||
components-changed)))))]
|
||||
|
||||
(when components-v2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue