0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 15:51:37 -05:00

🐛 Fix repair script for invalid-main-instance-page

This commit is contained in:
Pablo Alba 2023-10-20 14:40:56 +02:00 committed by Andrés Moya
parent 349b6f6fce
commit c2b470a4c6
2 changed files with 26 additions and 24 deletions

View file

@ -191,7 +191,7 @@
(log/info :hint "Repairing shape :invalid-main-instance-page" :id (:id shape) :name (:name shape) :page-id page-id)
(-> (pcb/empty-changes nil page-id)
(pcb/with-library-data file-data)
(pcb/update-component [(:component-id shape)] repair-component))))
(pcb/update-component (:component-id shape) repair-component))))
(defmethod repair-error :invalid-main-instance
[_ {:keys [shape page-id] :as error} file-data _]

View file

@ -167,7 +167,8 @@
(let [components-v2 (dm/get-in file-data [:options :components-v2])]
(if (and components-v2 (not (:deleted component)))
(let [component-page (get-component-page file-data component)]
(ctn/get-shape component-page shape-id))
(when component-page
(ctn/get-shape component-page shape-id)))
(dm/get-in component [:objects shape-id]))))
(defn get-ref-shape
@ -181,9 +182,10 @@
referenced by the instance shape."
[file page libraries shape & {:keys [include-deleted?] :or {include-deleted? false}}]
(let [root-shape (ctn/get-component-shape (:objects page) shape)
component-file (if (= (:component-file root-shape) (:id file))
component-file (when root-shape
(if (= (:component-file root-shape) (:id file))
file
(get libraries (:component-file root-shape)))
(get libraries (:component-file root-shape))))
component (when component-file
(ctkl/get-component (:data component-file) (:component-id root-shape) include-deleted?))
ref-shape (when component