diff --git a/common/src/app/common/files/defaults.cljc b/common/src/app/common/files/defaults.cljc index 721adab70f..5c15fc10d1 100644 --- a/common/src/app/common/files/defaults.cljc +++ b/common/src/app/common/files/defaults.cljc @@ -6,4 +6,4 @@ (ns app.common.files.defaults) -(def version 47) +(def version 48) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 363311564e..3b78031568 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -923,6 +923,20 @@ (-> data (update :pages-index update-vals update-page)))) +(defn migrate-up-48 + [data] + (letfn [(fix-shape [shape] + (let [swap-slot (ctk/get-swap-slot shape)] + (if (and (some? swap-slot) + (not (ctk/subcopy-head? shape))) + (ctk/remove-swap-slot shape) + shape))) + + (update-page [page] + (d/update-when page :objects update-vals fix-shape))] + (-> data + (update :pages-index update-vals update-page)))) + (def migrations "A vector of all applicable migrations" [{:id 2 :migrate-up migrate-up-2} @@ -961,4 +975,5 @@ {:id 44 :migrate-up migrate-up-44} {:id 45 :migrate-up migrate-up-45} {:id 46 :migrate-up migrate-up-46} - {:id 47 :migrate-up migrate-up-47}]) + {:id 47 :migrate-up migrate-up-47} + {:id 48 :migrate-up migrate-up-48}]) diff --git a/common/src/app/common/types/component.cljc b/common/src/app/common/types/component.cljc index 7c48e7f30d..95bf3016a5 100644 --- a/common/src/app/common/types/component.cljc +++ b/common/src/app/common/types/component.cljc @@ -130,6 +130,15 @@ (and (some? (:component-id shape)) (nil? (:component-root shape)))) +(defn subcopy-head? + "Check if this shape is the head of a subinstance that is a copy." + [shape] + ;; This is redundant with the previous one, but may give more security + ;; in case of bugs. + (and (some? (:component-id shape)) + (nil? (:component-root shape)) + (some? (:shape-ref shape)))) + (defn instance-of? [shape file-id component-id] (and (some? (:component-id shape)) @@ -227,7 +236,6 @@ :shape-ref :touched)) - (defn- extract-ids [shape] (if (map? shape) (let [current-id (:id shape)