From d16513be9dbfa2fc9c80678512c6d10058ed8ccb Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 9 Jan 2025 16:58:40 +0100 Subject: [PATCH] :bug: Fix error when importing files with touched components --- CHANGES.md | 6 ++++++ common/src/app/common/files/defaults.cljc | 2 +- common/src/app/common/files/migrations.cljc | 18 +++++++++++++++++- common/src/app/common/types/shape.cljc | 3 ++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8b2a77093..b2811d57c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # CHANGELOG +## 2.4.1 + +### :bug: Bugs fixed + +- Fix error when importing files with touched components [Taiga #9625](https://tree.taiga.io/project/penpot/issue/9625) + ## 2.4.0 ### :rocket: Epics and highlights diff --git a/common/src/app/common/files/defaults.cljc b/common/src/app/common/files/defaults.cljc index 21a8f304f..cd0c9b262 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 57) +(def version 59) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index f6245b13b..fe1efeb80 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -1130,6 +1130,21 @@ (update :pages-index dissoc nil) (update :pages-index update-vals update-page)))) +(defn migrate-up-59 + [data] + (letfn [(fix-touched [elem] + (cond-> elem (string? elem) keyword)) + + (update-shape [shape] + (d/update-when shape :touched #(into #{} (map fix-touched) %))) + + (update-container [container] + (d/update-when container :objects update-vals update-shape))] + + (-> data + (update :pages-index update-vals update-container) + (update :components update-vals update-container)))) + (def migrations "A vector of all applicable migrations" [{:id 2 :migrate-up migrate-up-2} @@ -1178,5 +1193,6 @@ {:id 54 :migrate-up migrate-up-54} {:id 55 :migrate-up migrate-up-55} {:id 56 :migrate-up migrate-up-56} - {:id 57 :migrate-up migrate-up-57}]) + {:id 57 :migrate-up migrate-up-57} + {:id 59 :migrate-up migrate-up-59}]) diff --git a/common/src/app/common/types/shape.cljc b/common/src/app/common/types/shape.cljc index ad9817490..fa0de5359 100644 --- a/common/src/app/common/types/shape.cljc +++ b/common/src/app/common/types/shape.cljc @@ -191,7 +191,8 @@ [:grow-type {:optional true} [::sm/one-of grow-types]] [:applied-tokens {:optional true} ::cto/applied-tokens] - [:plugin-data {:optional true} ::ctpg/plugin-data]]) + [:plugin-data {:optional true} ::ctpg/plugin-data] + [:touched {:optional true} [:maybe [:set :keyword]]]]) (def schema:group-attrs [:map {:title "GroupAttrs"}