mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -05:00
🐛 Add migration to remove all misplaced slots
This commit is contained in:
parent
3472359168
commit
5e8c164a44
3 changed files with 26 additions and 3 deletions
|
@ -6,4 +6,4 @@
|
|||
|
||||
(ns app.common.files.defaults)
|
||||
|
||||
(def version 47)
|
||||
(def version 48)
|
||||
|
|
|
@ -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}])
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue