mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 08:50:57 -05:00
Optimize the projects/pages loading.
This commit is contained in:
parent
944ebaa8f7
commit
3353c69a51
1 changed files with 14 additions and 7 deletions
|
@ -71,27 +71,34 @@
|
|||
(defn load-projects
|
||||
[]
|
||||
(letfn [(transform [state projects]
|
||||
(reduce stpr/assoc-project state projects))
|
||||
(as-> state $
|
||||
(reduce stpr/assoc-project $ projects)
|
||||
(assoc $ ::projects-loaded true)))
|
||||
(on-loaded [projects]
|
||||
#(transform % projects))]
|
||||
(reify
|
||||
rs/WatchEvent
|
||||
(-apply-watch [_ state]
|
||||
(if (::projects-loaded state)
|
||||
(rx/empty)
|
||||
(-> (rp/do :fetch/projects)
|
||||
(p/then on-loaded))))))
|
||||
(p/then on-loaded)))))))
|
||||
|
||||
(defn load-pages
|
||||
[]
|
||||
(letfn [(transform [state pages]
|
||||
(reduce stpr/assoc-page state pages))
|
||||
(as-> state $
|
||||
(reduce stpr/assoc-page $ pages)
|
||||
(assoc $ ::pages-loaded true)))
|
||||
(on-loaded [pages]
|
||||
#(transform % pages))]
|
||||
(reify
|
||||
rs/WatchEvent
|
||||
(-apply-watch [_ state]
|
||||
(println "load-pages")
|
||||
(if (::pages-loaded state)
|
||||
(rx/empty)
|
||||
(-> (rp/do :fetch/pages)
|
||||
(p/then on-loaded))))))
|
||||
(p/then on-loaded)))))))
|
||||
|
||||
(defn create-page
|
||||
[{:keys [name width height project layout] :as data}]
|
||||
|
|
Loading…
Reference in a new issue