From 54cee6ea72a70345e9f80280820e488e4cfe0b06 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 21 Jun 2023 18:16:13 +0200 Subject: [PATCH] :bug: Fix annotation is not duplicated together with main component --- common/src/app/common/pages/changes_builder.cljc | 9 ++++++--- common/src/app/common/types/components_list.cljc | 7 +++---- frontend/src/app/main/data/workspace/libraries.cljs | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/common/src/app/common/pages/changes_builder.cljc b/common/src/app/common/pages/changes_builder.cljc index 288ec1cfc..be93f9cc7 100644 --- a/common/src/app/common/pages/changes_builder.cljc +++ b/common/src/app/common/pages/changes_builder.cljc @@ -603,7 +603,9 @@ (apply-changes-local)))) (defn add-component - [changes id path name new-shapes updated-shapes main-instance-id main-instance-page] + ([changes id path name new-shapes updated-shapes main-instance-id main-instance-page] + (add-component changes id path name new-shapes updated-shapes main-instance-id main-instance-page nil)) + ([changes id path name new-shapes updated-shapes main-instance-id main-instance-page annotation] (assert-page-id changes) (assert-objects changes) (let [page-id (::page-id (meta changes)) @@ -641,7 +643,8 @@ :path path :name name :main-instance-id main-instance-id - :main-instance-page main-instance-page} + :main-instance-page main-instance-page + :annotation annotation} (some? new-shapes) ;; this will be null in components-v2 (assoc :shapes (vec new-shapes)))) (into (map mk-change) updated-shapes)))) @@ -655,7 +658,7 @@ (map lookupf) (map mk-change)) updated-shapes)))) - (apply-changes-local)))) + (apply-changes-local))))) (defn update-component [changes id update-fn] diff --git a/common/src/app/common/types/components_list.cljc b/common/src/app/common/types/components_list.cljc index 858a506ef..d5d37267e 100644 --- a/common/src/app/common/types/components_list.cljc +++ b/common/src/app/common/types/components_list.cljc @@ -30,13 +30,12 @@ (assoc component :modified-at (dt/now))) (defn add-component - [fdata {:keys [id name path main-instance-id main-instance-page shapes]}] + [fdata {:keys [id name path main-instance-id main-instance-page shapes annotation]}] (let [components-v2 (dm/get-in fdata [:options :components-v2]) fdata (update fdata :components assoc id (touch {:id id :name name :path path}))] (if components-v2 - (update-in fdata [:components id] assoc - :main-instance-id main-instance-id - :main-instance-page main-instance-page) + (cond-> (update-in fdata [:components id] assoc :main-instance-id main-instance-id :main-instance-page main-instance-page) + annotation (update-in [:components id] assoc :annotation annotation)) (let [wrap-object-fn feat/*wrap-with-objects-map-fn*] (assoc-in fdata [:components id :objects] diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index edff00bc3..c6901212a 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -423,7 +423,8 @@ new-component-shapes [] (:id new-main-instance-shape) - (:id main-instance-page)))] + (:id main-instance-page) + (:annotation component)))] (rx/of (dch/commit-changes changes))))))