mirror of
https://github.com/penpot/penpot.git
synced 2026-09-13 15:38:38 +00:00
🐛 Fix incorrect main instance creation on migration to v2
This commit is contained in:
parent
7d8e43b3d3
commit
f140ec4541
@ -271,9 +271,10 @@
|
|||||||
update-new-shape
|
update-new-shape
|
||||||
(fn [new-shape original-shape]
|
(fn [new-shape original-shape]
|
||||||
(let [new-name (:name new-shape)
|
(let [new-name (:name new-shape)
|
||||||
main-instance? (and main-instance? (ctk/instance-root? new-shape))] ; Only the instance root can be a main instance
|
root? (or (ctk/instance-root? original-shape) ; If shape is inside a component (not components-v2)
|
||||||
|
(nil? (:parent-id original-shape)))] ; we detect it by having no parent)
|
||||||
|
|
||||||
(when (nil? (:parent-id original-shape))
|
(when root?
|
||||||
(vswap! unames conj new-name))
|
(vswap! unames conj new-name))
|
||||||
|
|
||||||
(vswap! ids-map assoc (:id original-shape) (:id new-shape))
|
(vswap! ids-map assoc (:id original-shape) (:id new-shape))
|
||||||
@ -283,12 +284,15 @@
|
|||||||
(-> (gsh/move delta)
|
(-> (gsh/move delta)
|
||||||
(dissoc :touched))
|
(dissoc :touched))
|
||||||
|
|
||||||
main-instance?
|
(and main-instance? root?)
|
||||||
(assoc :main-instance true)
|
(assoc :main-instance true)
|
||||||
|
|
||||||
(not main-instance?)
|
(not main-instance?)
|
||||||
(dissoc :main-instance)
|
(dissoc :main-instance)
|
||||||
|
|
||||||
|
main-instance?
|
||||||
|
(dissoc :shape-ref)
|
||||||
|
|
||||||
(and (not main-instance?)
|
(and (not main-instance?)
|
||||||
(or components-v2 ; In v1, shape-ref points to the remote instance
|
(or components-v2 ; In v1, shape-ref points to the remote instance
|
||||||
(nil? (:shape-ref original-shape)))) ; in v2, shape-ref points to the near instance
|
(nil? (:shape-ref original-shape)))) ; in v2, shape-ref points to the near instance
|
||||||
@ -300,21 +304,17 @@
|
|||||||
:component-root true
|
:component-root true
|
||||||
:name new-name)
|
:name new-name)
|
||||||
|
|
||||||
(and (nil? (:parent-id original-shape)) main-instance? components-v2)
|
|
||||||
(assoc :main-instance true)
|
|
||||||
|
|
||||||
(some? (:parent-id original-shape))
|
(some? (:parent-id original-shape))
|
||||||
(dissoc :component-root))))
|
(dissoc :component-root))))
|
||||||
|
|
||||||
[new-shape new-shapes _]
|
[new-shape new-shapes _]
|
||||||
(ctst/clone-object
|
(ctst/clone-object component-shape
|
||||||
component-shape
|
nil
|
||||||
nil
|
(if components-v2 (:objects component-page) (:objects component))
|
||||||
(if components-v2 (:objects component-page) (:objects component))
|
update-new-shape
|
||||||
update-new-shape
|
(fn [object _] object)
|
||||||
(fn [object _] object)
|
force-id
|
||||||
force-id
|
keep-ids?)
|
||||||
keep-ids?)
|
|
||||||
|
|
||||||
;; If frame-id points to a shape inside the component, remap it to the
|
;; If frame-id points to a shape inside the component, remap it to the
|
||||||
;; corresponding new frame shape. If not, set it to the destination frame.
|
;; corresponding new frame shape. If not, set it to the destination frame.
|
||||||
|
|||||||
@ -394,7 +394,7 @@
|
|||||||
file-data
|
file-data
|
||||||
position
|
position
|
||||||
false
|
false
|
||||||
{:main-instance true
|
{:main-instance? true
|
||||||
:force-frame-id uuid/zero
|
:force-frame-id uuid/zero
|
||||||
:keep-ids? true})
|
:keep-ids? true})
|
||||||
add-shapes
|
add-shapes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user