mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 09:18:37 +02:00
Denormalize shapes storage.
This commit is contained in:
parent
40bbc996f7
commit
a4fe43235b
7 changed files with 40 additions and 23 deletions
|
@ -16,14 +16,22 @@
|
|||
to the state map."
|
||||
[state color-coll]
|
||||
(let [uuid (:id color-coll)]
|
||||
(update-in state [:colors-by-id] assoc uuid color-coll)))
|
||||
(update state :colors-by-id assoc uuid color-coll)))
|
||||
|
||||
(defn assoc-shape
|
||||
[state shape]
|
||||
(let [id (:id shape)]
|
||||
(update state :shapes-by-id assoc id shape)))
|
||||
|
||||
(defn persist-state
|
||||
[state]
|
||||
(let [pages (into #{} (vals (:pages-by-id state)))
|
||||
projects (into #{} (vals (:projects-by-id state)))
|
||||
shapes (into #{} (vals (:shapes-by-id state)))
|
||||
color-colls (into #{} (vals (:colors-by-id state)))]
|
||||
|
||||
(assoc! local-storage :data {:pages pages
|
||||
:shapes shapes
|
||||
:projects projects
|
||||
:color-collections color-colls})))
|
||||
|
||||
|
@ -41,6 +49,7 @@
|
|||
(as-> state $
|
||||
(reduce dp/assoc-project $ (:projects data))
|
||||
(reduce dp/assoc-page $ (:pages data))
|
||||
(reduce assoc-color $ (:color-collections data)))
|
||||
(reduce assoc-color $ (:color-collections data))
|
||||
(reduce assoc-shape $ (:shapes data)))
|
||||
state))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue