From 0392a1649f49e3000b4752eb063b747a6f198163 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 30 Mar 2022 12:27:30 +0200 Subject: [PATCH] :bug: Remove default fill-color and fill-opacity on image shapes --- common/src/app/common/pages/common.cljc | 2 +- common/src/app/common/pages/migrations.cljc | 23 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/pages/common.cljc b/common/src/app/common/pages/common.cljc index 43cd9371cf..b66aa935ff 100644 --- a/common/src/app/common/pages/common.cljc +++ b/common/src/app/common/pages/common.cljc @@ -9,7 +9,7 @@ [app.common.colors :as clr] [app.common.uuid :as uuid])) -(def file-version 13) +(def file-version 14) (def default-color clr/gray-20) (def root uuid/zero) diff --git a/common/src/app/common/pages/migrations.cljc b/common/src/app/common/pages/migrations.cljc index d87f2156e8..5f0723250c 100644 --- a/common/src/app/common/pages/migrations.cljc +++ b/common/src/app/common/pages/migrations.cljc @@ -12,7 +12,8 @@ [app.common.geom.shapes.path :as gsp] [app.common.math :as mth] [app.common.pages :as cp] - [app.common.uuid :as uuid])) + [app.common.uuid :as uuid] + [cuerdas.core :as str])) ;; TODO: revisit this and rename to file-migrations @@ -300,3 +301,23 @@ (update page :objects #(d/mapm update-object %)))] (update data :pages-index #(d/mapm update-page %)))) + +(defmethod migrate 14 + [data] + (letfn [(update-object [_ {:keys [type] :as object}] + (if (= :image type) + (let [fill-color (str/upper (:fill-color object)) + fill-opacity (:fill-opacity object)] + (cond-> object + (and (= 1 fill-opacity) + (or (= "#B1B2B5" fill-color) + (= "#7B7D85" fill-color))) + (dissoc :fill-color :fill-opacity))) + object)) + + (update-container [_ container] + (update container :objects #(d/mapm update-object %)))] + + (-> data + (update :pages-index #(d/mapm update-container %)) + (update :components #(d/mapm update-container %)))))