mirror of
https://github.com/penpot/penpot.git
synced 2025-07-25 21:37:27 +02:00
♻️ Components refactor: generator for restore-component
This commit is contained in:
parent
f91d60eeb6
commit
7d44eef4ab
3 changed files with 27 additions and 20 deletions
|
@ -488,22 +488,11 @@
|
|||
(watch [it state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
current-page (dm/get-in state [:workspace-data :pages-index page-id])
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
library-data (wsh/get-file state library-id)
|
||||
{:keys [changes shape]} (cflh/prepare-restore-component library-data component-id current-page it)
|
||||
parent-id (:parent-id shape)
|
||||
objects (cond-> (assoc objects (:id shape) shape)
|
||||
(not (nil? parent-id))
|
||||
(update-in [parent-id :shapes]
|
||||
#(conj % (:id shape))))
|
||||
|
||||
;; Adds a resize-parents operation so the groups are updated. We add all the new objects
|
||||
new-objects-ids (->> changes :redo-changes (filter #(= (:type %) :add-obj)) (mapv :id))
|
||||
changes (-> changes
|
||||
(pcb/with-objects objects)
|
||||
(pcb/resize-parents new-objects-ids))]
|
||||
|
||||
(rx/of (dch/commit-changes (assoc changes :file-id library-id)))))))
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
changes (-> (pcb/empty-changes it)
|
||||
(cflh/generate-restore-component library-data component-id library-id current-page objects))]
|
||||
(rx/of (dch/commit-changes changes))))))
|
||||
|
||||
|
||||
(defn restore-components
|
||||
|
|
|
@ -447,7 +447,7 @@
|
|||
{})
|
||||
|
||||
restore-component
|
||||
#(let [restore (cflh/prepare-restore-component changes library-data (:component-id component-root) it page delta (:id component-root) parent-id frame-id)]
|
||||
#(let [restore (cflh/prepare-restore-component changes library-data (:component-id component-root) page delta (:id component-root) parent-id frame-id)]
|
||||
[(:shape restore) (:changes restore)])
|
||||
|
||||
[_shape changes]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue