From f5904cee5983f7a7098e3a678528b9c2c453d4ba Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 13 Dec 2023 16:49:32 +0100 Subject: [PATCH] :bug: Validate and repair also orphan shapes --- common/src/app/common/files/validate.cljc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/files/validate.cljc b/common/src/app/common/files/validate.cljc index 23daff25d..4864bbc41 100644 --- a/common/src/app/common/files/validate.cljc +++ b/common/src/app/common/files/validate.cljc @@ -474,7 +474,14 @@ [{:keys [data features] :as file} libraries] (when (contains? features "components/v2") (doseq [page (filter :id (ctpl/pages-seq data))] - (validate-shape! uuid/zero file page libraries)) + (let [orphans (->> page + :objects + vals + (filter #(not (contains? (:objects page) (:parent-id %)))) + (map :id))] + (validate-shape! uuid/zero file page libraries) + (doseq [shape-id orphans] + (validate-shape! shape-id file page libraries)))) (doseq [component (vals (:components data))] (validate-component! component file)))