🐛 Add migration for fix bool shapes which does not have :bool-content attr

This commit is contained in:
Andrey Antukh 2024-01-16 19:18:08 +01:00
parent 33ad2d94fb
commit b582998228
2 changed files with 43 additions and 24 deletions

View File

@ -6,4 +6,4 @@
(ns app.common.files.defaults) (ns app.common.files.defaults)
(def version 38) (def version 39)

View File

@ -319,18 +319,20 @@
(dissoc :fill-color :fill-opacity)))) (dissoc :fill-color :fill-opacity))))
(update-container [{:keys [objects] :as container}] (update-container [{:keys [objects] :as container}]
(loop [objects objects (if (contains? container :objects)
shapes (->> (vals objects) (loop [objects (:objects container)
(filter cfh/image-shape?))] shapes (->> (vals objects)
(if-let [shape (first shapes)] (filter cfh/image-shape?))]
(let [{:keys [id frame-id] :as shape'} (process-shape shape)] (if-let [shape (first shapes)]
(if (identical? shape shape') (let [{:keys [id frame-id] :as shape'} (process-shape shape)]
(recur objects (rest shapes)) (if (identical? shape shape')
(recur (-> objects (recur objects (rest shapes))
(assoc id shape') (recur (-> objects
(d/update-when frame-id dissoc :thumbnail)) (assoc id shape')
(rest shapes)))) (d/update-when frame-id dissoc :thumbnail))
(assoc container :objects objects))))] (rest shapes))))
(assoc container :objects objects)))
container))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
@ -380,7 +382,7 @@
(assign-fills))) (assign-fills)))
(update-container [container] (update-container [container]
(update container :objects update-vals update-object))] (d/update-when container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
@ -409,7 +411,7 @@
(assoc :fills []))) (assoc :fills [])))
(update-container [container] (update-container [container]
(update container :objects update-vals update-object))] (d/update-when container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
@ -424,7 +426,7 @@
(dissoc :position-data))) (dissoc :position-data)))
(update-container [container] (update-container [container]
(update container :objects update-vals update-object))] (d/update-when container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
@ -440,7 +442,7 @@
(dissoc :position-data))) (dissoc :position-data)))
(update-container [container] (update-container [container]
(update container :objects update-vals update-object))] (d/update-when container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
@ -527,7 +529,7 @@
(assoc object :frame-id calculated-frame-id))) (assoc object :frame-id calculated-frame-id)))
(update-container [container] (update-container [container]
(update container :objects #(update-vals % (partial update-object %))))] (d/update-when container :objects #(update-vals % (partial update-object %))))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
@ -565,7 +567,7 @@
(update :content #(txt/transform-nodes invalid-node? fix-node %))))) (update :content #(txt/transform-nodes invalid-node? fix-node %)))))
(update-container [container] (update-container [container]
(update container :objects update-vals update-object))] (d/update-when container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
@ -580,7 +582,7 @@
object)) object))
(update-container [container] (update-container [container]
(update container :objects update-vals update-object))] (d/update-when container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
@ -613,7 +615,8 @@
object))) object)))
(update-container [container] (update-container [container]
(update container :objects update-vals update-object))] (d/update-when container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
(update :components update-vals update-container)))) (update :components update-vals update-container))))
@ -630,7 +633,7 @@
object)) object))
(update-container [container] (update-container [container]
(update container :objects update-vals update-object))] (d/update-when container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index update-vals update-container)))) (update :pages-index update-vals update-container))))
@ -642,7 +645,7 @@
(dissoc object :x :y :width :height) (dissoc object :x :y :width :height)
object)) object))
(update-container [container] (update-container [container]
(update container :objects update-vals update-object))] (d/update-when container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
(update :components update-vals update-container)))) (update :components update-vals update-container))))
@ -694,7 +697,23 @@
shape))) shape)))
(update-container [container] (update-container [container]
(update container :objects update-vals update-shape))] (d/update-when container :objects update-vals update-shape))]
(-> data
(update :pages-index update-vals update-container)
(update :components update-vals update-container))))
(defmethod migrate 39
[data]
(letfn [(update-shape [shape]
(if (and (cfh/bool-shape? shape)
(not (contains? shape :bool-content)))
(assoc shape :bool-content [])
shape))
(update-container [container]
(d/update-when container :objects update-vals update-shape))]
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)