mirror of
https://github.com/penpot/penpot.git
synced 2025-05-06 02:45:54 +02:00
🐛 Add workaround for unexpected exception on fix-broken-shapes
which happens when we have a component shape tree with an ephimeral shape with id ZERO (unused and with invalid children)
This commit is contained in:
parent
7afaa9d31f
commit
6e313dff84
1 changed files with 19 additions and 4 deletions
|
@ -11,13 +11,28 @@
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(defn- generate-changes
|
(defn- generate-changes
|
||||||
[attr {:keys [objects id]}]
|
[attr {:keys [objects id] :as container}]
|
||||||
(let [base {:type :fix-obj attr id}
|
(let [base {:type :fix-obj attr id}
|
||||||
contains? (partial contains? objects)
|
contains? (partial contains? objects)
|
||||||
xform (comp
|
xform (comp
|
||||||
(remove #(every? contains? (:shapes %)))
|
;; FIXME: Ensure all obj have id field (this is needed
|
||||||
(map #(assoc base :id (:id %))))]
|
;; because some bug adds an ephimeral shape with id ZERO,
|
||||||
(sequence xform (vals objects))))
|
;; with a single attr `:shapes` having a vector of ids
|
||||||
|
;; pointing to not existing shapes). That happens on
|
||||||
|
;; components. THIS IS A WORKAOURD
|
||||||
|
(map (fn [[id obj]]
|
||||||
|
(if (some? (:id obj))
|
||||||
|
obj
|
||||||
|
(assoc obj :id id))))
|
||||||
|
|
||||||
|
;; Remove all valid shapes
|
||||||
|
(remove (fn [obj]
|
||||||
|
(every? contains? (:shapes obj))))
|
||||||
|
|
||||||
|
(map (fn [obj]
|
||||||
|
(assoc base :id (:id obj)))))]
|
||||||
|
|
||||||
|
(sequence xform objects)))
|
||||||
|
|
||||||
(defn fix-broken-shapes
|
(defn fix-broken-shapes
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Add table
Reference in a new issue