0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 15:39:50 -05:00

🐛 Fix recent colors on components migration

This commit is contained in:
Andrey Antukh 2024-01-16 19:29:17 +01:00
parent 0a5e15b916
commit ec1bcada86
2 changed files with 13 additions and 4 deletions

View file

@ -21,8 +21,10 @@
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.logging :as l] [app.common.logging :as l]
[app.common.math :as mth] [app.common.math :as mth]
[app.common.schema :as sm]
[app.common.svg :as csvg] [app.common.svg :as csvg]
[app.common.svg.shapes-builder :as sbuilder] [app.common.svg.shapes-builder :as sbuilder]
[app.common.types.color :as ctc]
[app.common.types.component :as ctk] [app.common.types.component :as ctk]
[app.common.types.components-list :as ctkl] [app.common.types.components-list :as ctkl]
[app.common.types.container :as ctn] [app.common.types.container :as ctn]
@ -113,6 +115,13 @@
(vswap! detached-ids conj (:id shape))) (vswap! detached-ids conj (:id shape)))
(ctk/detach-shape shape))) (ctk/detach-shape shape)))
fix-recent-colors
(fn [file-data]
(let [valid-color? (sm/validator ::ctc/recent-color)]
(d/update-when file-data :recent-colors
(fn [colors]
(filterv valid-color? colors)))))
fix-orphan-shapes fix-orphan-shapes
(fn [file-data] (fn [file-data]
;; Find shapes that are not listed in their parent's children list. ;; Find shapes that are not listed in their parent's children list.
@ -344,6 +353,7 @@
(update :components update-vals fix-container))))] (update :components update-vals fix-container))))]
(-> file-data (-> file-data
(fix-recent-colors)
(fix-orphan-shapes) (fix-orphan-shapes)
(remove-nested-roots) (remove-nested-roots)
(add-not-nested-roots) (add-not-nested-roots)
@ -735,7 +745,7 @@
(defn- create-media-grid (defn- create-media-grid
[fdata page-id frame-id grid media-group] [fdata page-id frame-id grid media-group]
(letfn [(process-media-object [fdata mobj position] (letfn [(process [fdata mobj position]
(let [position (gpt/add position (gpt/point grid-gap grid-gap)) (let [position (gpt/add position (gpt/point grid-gap grid-gap))
tp (dt/tpoint) tp (dt/tpoint)
err (volatile! false)] err (volatile! false)]
@ -785,8 +795,7 @@
(sse/tap {:type :migration-progress (sse/tap {:type :migration-progress
:section :graphics :section :graphics
:name (:name mobj)}) :name (:name mobj)})
(or (process-media-object fdata mobj position) (or (process fdata mobj position) fdata))
fdata))
(assoc-in fdata [:options :components-v2] true))))) (assoc-in fdata [:options :components-v2] true)))))
(defn- migrate-graphics (defn- migrate-graphics

View file

@ -204,7 +204,7 @@
sprocs (ps/create :permits max-procs) sprocs (ps/create :permits max-procs)
cache (if (int? cache) cache (if (int? cache)
(cache/create :executor (::wrk/executor main/system) (cache/create :executor :same-thread
:max-items cache) :max-items cache)
nil) nil)