From 166d2b7b68d7ed3e6e2a4c0a84ab4ed6e2684593 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 18 Jan 2024 11:56:57 +0100 Subject: [PATCH] :bug: Fix broken fills and strokes on comp-v2 migration --- backend/src/app/features/components_v2.clj | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/src/app/features/components_v2.clj b/backend/src/app/features/components_v2.clj index baf72e941..9af03ab4a 100644 --- a/backend/src/app/features/components_v2.clj +++ b/backend/src/app/features/components_v2.clj @@ -105,6 +105,9 @@ or that are the result of old bugs." [file-data libraries] (let [detached-ids (volatile! #{}) + valid-color? (sm/validator ::ctc/recent-color) + valid-fill? (sm/validator ::cts/fill) + valid-stroke? (sm/validator ::cts/stroke) detach-shape (fn [container shape] @@ -115,7 +118,6 @@ (vswap! detached-ids conj (:id shape))) (ctk/detach-shape shape))) - fix-missing-image-metadata (fn [file-data] (let [update-object @@ -152,6 +154,14 @@ 0 gap))) + ;; Fix broken fills + (seq (:fills shape)) + (update :fills (fn [fills] (filterv valid-fill? fills))) + + ;; Fix broken strokes + (seq (:strokes shape)) + (update :strokes (fn [strokes] (filterv valid-stroke? strokes))) + ;; Fix some broken layout related attrs, probably ;; of copypaste on flex layout betatest period (true? (:layout shape)) @@ -171,10 +181,9 @@ fix-recent-colors (fn [file-data] - (let [valid-color? (sm/validator ::ctc/recent-color)] - (d/update-when file-data :recent-colors - (fn [colors] - (filterv valid-color? colors))))) + (d/update-when file-data :recent-colors + (fn [colors] + (filterv valid-color? colors)))) fix-orphan-shapes (fn [file-data]