mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 00:58:26 -05:00
Simplify project manipulation state functions.
This commit is contained in:
parent
6492faefd4
commit
3e4678a085
1 changed files with 19 additions and 3 deletions
|
@ -11,9 +11,8 @@
|
|||
(defn dissoc-project
|
||||
"A reduce function for dissoc the project
|
||||
from the state map."
|
||||
[state proj]
|
||||
(let [uuid (:id proj)]
|
||||
(update-in state [:projects-by-id] dissoc uuid)))
|
||||
[state id]
|
||||
(update-in state [:projects-by-id] dissoc id))
|
||||
|
||||
(defn assoc-page
|
||||
"A reduce function for assoc the page
|
||||
|
@ -22,6 +21,23 @@
|
|||
(let [uuid (:id page)]
|
||||
(update-in state [:pages-by-id] assoc uuid page)))
|
||||
|
||||
(defn dissoc-page-shapes
|
||||
[state id]
|
||||
(let [shapes (get-in state [:shapes-by-id])]
|
||||
(assoc state :shapes-by-id (reduce-kv (fn [acc k v]
|
||||
(if (= (:page v) id)
|
||||
(dissoc acc k)
|
||||
acc))
|
||||
shapes
|
||||
shapes))))
|
||||
|
||||
(defn dissoc-page
|
||||
"Remove page and all related stuff from the state."
|
||||
[state id]
|
||||
(-> state
|
||||
(update :pages-by-id dissoc id)
|
||||
(dissoc-page-shapes id)))
|
||||
|
||||
(defn project-pages
|
||||
"Get a ordered list of pages that
|
||||
belongs to a specified project."
|
||||
|
|
Loading…
Add table
Reference in a new issue