0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-14 19:19:09 -05:00

🐛 Fix ordering when restoring deleted shapes in sync

This commit is contained in:
Andrés Moya 2021-02-11 10:58:58 +01:00 committed by Alonso Torres
parent 608b5cc9f9
commit 4b8334fe1c
2 changed files with 17 additions and 10 deletions

View file

@ -27,6 +27,7 @@
- Fix logo icon in viewer should go to dashboard - Fix logo icon in viewer should go to dashboard
- Fix text alignment in preview [#594](https://github.com/penpot/penpot/issues/594) - Fix text alignment in preview [#594](https://github.com/penpot/penpot/issues/594)
- Fix problem when pasting URL's copied from the browser url bar - Fix problem when pasting URL's copied from the browser url bar
- Fix ordering when restoring deleted shapes in sync [Taiga #1163](https://tree.taiga.io/project/penpot/issue/1163)
### Community contributions by (Thank you! :heart:) ### Community contributions by (Thank you! :heart:)

View file

@ -626,6 +626,8 @@
(contains? (:touched shape-inst) (contains? (:touched shape-inst)
:shapes-group)) :shapes-group))
(add-shape-to-instance child-master (add-shape-to-instance child-master
(d/index-of children-master
child-master)
component component
container container
root-inst root-inst
@ -649,11 +651,11 @@
reset? reset?
initial-root?))) initial-root?)))
moved (fn [shape-inst shape-master] moved (fn [child-inst child-master]
(move-shape (move-shape
shape-inst child-inst
(d/index-of children-inst shape-inst) (d/index-of children-inst child-inst)
(d/index-of children-master shape-master) (d/index-of children-master child-master)
container container
omit-touched?)) omit-touched?))
@ -742,6 +744,8 @@
only-inst (fn [child-inst] only-inst (fn [child-inst]
(add-shape-to-master child-inst (add-shape-to-master child-inst
(d/index-of children-inst
child-inst)
component component
container container
root-inst root-inst
@ -768,11 +772,11 @@
root-master) root-master)
initial-root?))) initial-root?)))
moved (fn [shape-inst shape-master] moved (fn [child-inst child-master]
(move-shape (move-shape
shape-master child-master
(d/index-of children-master shape-master) (d/index-of children-master child-master)
(d/index-of children-inst shape-inst) (d/index-of children-inst child-inst)
component-container component-container
false)) false))
@ -863,7 +867,7 @@
(concat-changes (moved-cb child-inst' child-master)))))))))))) (concat-changes (moved-cb child-inst' child-master))))))))))))
(defn- add-shape-to-instance (defn- add-shape-to-instance
[component-shape component container root-instance root-master omit-touched? set-remote-synced?] [component-shape index component container root-instance root-master omit-touched? set-remote-synced?]
(log/info :msg (str "ADD [P] " (:name component-shape))) (log/info :msg (str "ADD [P] " (:name component-shape)))
(let [component-parent-shape (cp/get-shape component (:parent-id component-shape)) (let [component-parent-shape (cp/get-shape component (:parent-id component-shape))
parent-shape (d/seek #(cp/is-master-of component-parent-shape %) parent-shape (d/seek #(cp/is-master-of component-parent-shape %)
@ -904,6 +908,7 @@
(as-> {:type :add-obj (as-> {:type :add-obj
:id (:id shape') :id (:id shape')
:parent-id (:parent-id shape') :parent-id (:parent-id shape')
:index index
:ignore-touched true :ignore-touched true
:obj shape'} $ :obj shape'} $
(cond-> $ (cond-> $
@ -929,7 +934,7 @@
[rchanges uchanges]))) [rchanges uchanges])))
(defn- add-shape-to-master (defn- add-shape-to-master
[shape component page root-instance root-master] [shape index component page root-instance root-master]
(log/info :msg (str "ADD [C] " (:name shape))) (log/info :msg (str "ADD [C] " (:name shape)))
(let [parent-shape (cp/get-shape page (:parent-id shape)) (let [parent-shape (cp/get-shape page (:parent-id shape))
component-parent-shape (d/seek #(cp/is-master-of % parent-shape) component-parent-shape (d/seek #(cp/is-master-of % parent-shape)
@ -963,6 +968,7 @@
:id (:id shape') :id (:id shape')
:component-id (:id component) :component-id (:id component)
:parent-id (:parent-id shape') :parent-id (:parent-id shape')
:index index
:ignore-touched true :ignore-touched true
:obj shape'}) :obj shape'})
new-shapes) new-shapes)