From 3178eca8bbed710901f1560ac64152681c344eba Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 7 May 2025 15:03:50 +0200 Subject: [PATCH] :bug: Fix restore totally deleted variant should add props as name --- common/src/app/common/logic/libraries.cljc | 10 +++++----- common/src/app/common/logic/variant_properties.cljc | 10 ---------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 2566f51f279..11d0ca116ab 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -442,12 +442,12 @@ changes (rest moved-shapes)) changes (cond-> changes - ;; Transform variant info into name when restoring into a parent that is not a variant-container - (and is-variant? parent (not (ctk/is-variant-container? parent))) + ;; Transform variant info into name when restoring into a parent that is not a variant-container, + ;; or when restoring into a variant-container that doesn't exists anymore + (and is-variant? + (or (and parent (not (ctk/is-variant-container? parent))) + (nil? restoring-into-parent))) (clvp/generate-make-shapes-no-variant [first-shape]) - ;; Remove variant info when restoring into a variant-container that doesn't exists anymore - (and is-variant? (nil? restoring-into-parent)) - (clvp/generate-delete-variant-info first-shape) ;; Add variant info and rename when restoring into a variant-container (ctk/is-variant-container? restoring-into-parent) (clvp/generate-make-shapes-variant [first-shape] restoring-into-parent))] diff --git a/common/src/app/common/logic/variant_properties.cljc b/common/src/app/common/logic/variant_properties.cljc index fd4acd7016c..8731e509da1 100644 --- a/common/src/app/common/logic/variant_properties.cljc +++ b/common/src/app/common/logic/variant_properties.cljc @@ -93,16 +93,6 @@ related-components)] changes)) - -(defn generate-delete-variant-info - [changes shape] - (-> changes - (pcb/update-component (:component-id shape) - #(dissoc % :variant-id :variant-properties) - {:apply-changes-local-library? true}) - (pcb/update-shapes [(:id shape)] - #(dissoc % :variant-id :variant-name)))) - (defn- generate-make-shape-no-variant [changes shape] (let [new-name (ctv/variant-name-to-name shape)