mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
✨ Improve migration 14
Remove frame thumbnail if the migration modifies a shape.
This commit is contained in:
parent
f0d956f71c
commit
4c6433b0f1
1 changed files with 21 additions and 12 deletions
|
@ -304,19 +304,28 @@
|
||||||
|
|
||||||
(defmethod migrate 14
|
(defmethod migrate 14
|
||||||
[data]
|
[data]
|
||||||
(letfn [(update-object [_ {:keys [type] :as object}]
|
(letfn [(process-shape [shape]
|
||||||
(if (= :image type)
|
(let [fill-color (str/upper (:fill-color shape))
|
||||||
(let [fill-color (str/upper (:fill-color object))
|
fill-opacity (:fill-opacity shape)]
|
||||||
fill-opacity (:fill-opacity object)]
|
(cond-> shape
|
||||||
(cond-> object
|
(and (= 1 fill-opacity)
|
||||||
(and (= 1 fill-opacity)
|
(or (= "#B1B2B5" fill-color)
|
||||||
(or (= "#B1B2B5" fill-color)
|
(= "#7B7D85" fill-color)))
|
||||||
(= "#7B7D85" fill-color)))
|
(dissoc :fill-color :fill-opacity))))
|
||||||
(dissoc :fill-color :fill-opacity)))
|
|
||||||
object))
|
|
||||||
|
|
||||||
(update-container [_ container]
|
(update-container [_ {:keys [objects] :as container}]
|
||||||
(update container :objects #(d/mapm update-object %)))]
|
(loop [objects objects
|
||||||
|
shapes (->> (vals objects)
|
||||||
|
(filter #(= :image (:type %))))]
|
||||||
|
(if-let [shape (first shapes)]
|
||||||
|
(let [{:keys [id frame-id] :as shape'} (process-shape shape)]
|
||||||
|
(if (identical? shape shape')
|
||||||
|
(recur objects (rest shapes))
|
||||||
|
(recur (-> objects
|
||||||
|
(assoc id shape')
|
||||||
|
(d/update-when frame-id dissoc :thumbnail))
|
||||||
|
(rest shapes))))
|
||||||
|
(assoc container :objects objects))))]
|
||||||
|
|
||||||
(-> data
|
(-> data
|
||||||
(update :pages-index #(d/mapm update-container %))
|
(update :pages-index #(d/mapm update-container %))
|
||||||
|
|
Loading…
Add table
Reference in a new issue