mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -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
|
(defn load-projects
|
||||||
[]
|
[]
|
||||||
(letfn [(transform [state 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]
|
(on-loaded [projects]
|
||||||
#(transform % projects))]
|
#(transform % projects))]
|
||||||
(reify
|
(reify
|
||||||
rs/WatchEvent
|
rs/WatchEvent
|
||||||
(-apply-watch [_ state]
|
(-apply-watch [_ state]
|
||||||
(-> (rp/do :fetch/projects)
|
(if (::projects-loaded state)
|
||||||
(p/then on-loaded))))))
|
(rx/empty)
|
||||||
|
(-> (rp/do :fetch/projects)
|
||||||
|
(p/then on-loaded)))))))
|
||||||
|
|
||||||
(defn load-pages
|
(defn load-pages
|
||||||
[]
|
[]
|
||||||
(letfn [(transform [state 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]
|
(on-loaded [pages]
|
||||||
#(transform % pages))]
|
#(transform % pages))]
|
||||||
(reify
|
(reify
|
||||||
rs/WatchEvent
|
rs/WatchEvent
|
||||||
(-apply-watch [_ state]
|
(-apply-watch [_ state]
|
||||||
(println "load-pages")
|
(if (::pages-loaded state)
|
||||||
(-> (rp/do :fetch/pages)
|
(rx/empty)
|
||||||
(p/then on-loaded))))))
|
(-> (rp/do :fetch/pages)
|
||||||
|
(p/then on-loaded)))))))
|
||||||
|
|
||||||
(defn create-page
|
(defn create-page
|
||||||
[{:keys [name width height project layout] :as data}]
|
[{:keys [name width height project layout] :as data}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue