From 0547eebf85cf433dc9da0ac20203d310be417a81 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 18 Oct 2023 12:54:03 +0200 Subject: [PATCH 1/2] :bug: Set correct version on importing --- backend/src/app/rpc/commands/binfile.clj | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index 99dd69a68..de6b184d0 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -680,12 +680,17 @@ (let [file-id' (lookup-index file-id) data (-> (:data file) - (assoc :id file-id') + (assoc :id file-id')) + + data (if (> (:version data) cfd/version) + (assoc data :version cfd/version) + data) + + data (-> data (cond-> migrate? (pmg/migrate-data)) (update :pages-index relink-shapes) (update :components relink-shapes) (update :media relink-media) - (assoc :version cfd/version) (postprocess-file)) params {:id file-id' From da0f51c5a697e8d60fd7f3b8b143cc5fb9ac4bd8 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 18 Oct 2023 13:08:01 +0200 Subject: [PATCH 2/2] :bug: Fix :bool path handling on setup-shape --- common/src/app/common/files/defaults.cljc | 2 +- common/src/app/common/files/migrations.cljc | 14 ++++++++++++++ common/src/app/common/types/shape.cljc | 5 +++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/files/defaults.cljc b/common/src/app/common/files/defaults.cljc index 14480bc46..177dac915 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 33) +(def version 34) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 35a8b366d..61aa62df1 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -624,3 +624,17 @@ (update container :objects update-vals update-object))] (-> data (update :pages-index update-vals update-container)))) + +(defmethod migrate 34 + [data] + (letfn [(update-object [object] + (if (or (cph/path-shape? object) + (cph/bool-shape? object)) + (dissoc object :x :y :width :height) + object)) + (update-container [container] + (update container :objects update-vals update-object))] + (-> data + (update :pages-index update-vals update-container) + (update :components update-vals update-container)))) + diff --git a/common/src/app/common/types/shape.cljc b/common/src/app/common/types/shape.cljc index cb296bf4e..37c8bbe31 100644 --- a/common/src/app/common/types/shape.cljc +++ b/common/src/app/common/types/shape.cljc @@ -433,7 +433,8 @@ attrs (get-minimal-shape type)] (cond-> attrs - (not= :path type) + (and (not= :path type) + (not= :bool type)) (-> (assoc :x 0) (assoc :y 0) (assoc :width 0.01) @@ -481,7 +482,7 @@ (let [shape (make-minimal-shape type) shape (merge shape (d/without-nils props)) shape (case (:type shape) - :path (setup-path shape) + (:bool :path) (setup-path shape) :image (-> shape setup-rect setup-image) (setup-rect shape))] (-> shape