mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 12:48:33 +02:00
♻️ Refactor dashboard state management.
Mainly for performance, also affects backend endpoints.
This commit is contained in:
parent
e7b3f12b71
commit
c70bc5baff
23 changed files with 1110 additions and 1007 deletions
|
@ -47,6 +47,30 @@
|
|||
(def dashboard-fonts
|
||||
(l/derived :dashboard-fonts st/state))
|
||||
|
||||
(def dashboard-projects
|
||||
(l/derived :dashboard-projects st/state))
|
||||
|
||||
(def dashboard-files
|
||||
(l/derived :dashboard-files st/state))
|
||||
|
||||
(def dashboard-shared-files
|
||||
(l/derived :dashboard-shared-files st/state))
|
||||
|
||||
(def dashboard-search-result
|
||||
(l/derived :dashboard-search-result st/state))
|
||||
|
||||
(def dashboard-team
|
||||
(l/derived (fn [state]
|
||||
(let [team-id (:current-team-id state)]
|
||||
(get-in state [:teams team-id])))
|
||||
st/state))
|
||||
|
||||
(def dashboard-team-stats
|
||||
(l/derived :dashboard-team-stats st/state))
|
||||
|
||||
(def dashboard-team-members
|
||||
(l/derived :dashboard-team-members st/state))
|
||||
|
||||
(def dashboard-selected-project
|
||||
(l/derived (fn [state]
|
||||
(get-in state [:dashboard-local :selected-project]))
|
||||
|
@ -54,17 +78,14 @@
|
|||
|
||||
(def dashboard-selected-files
|
||||
(l/derived (fn [state]
|
||||
(get-in state [:dashboard-local :selected-files] #{}))
|
||||
st/state))
|
||||
|
||||
(def dashboard-selected-file-objs
|
||||
(l/derived (fn [state]
|
||||
(let [dashboard-local (get state :dashboard-local)
|
||||
selected-project (get dashboard-local :selected-project)
|
||||
selected-files (get dashboard-local :selected-files #{})]
|
||||
(map #(get-in state [:files selected-project %])
|
||||
selected-files)))
|
||||
st/state))
|
||||
(let [get-file #(get-in state [:dashboard-files %])
|
||||
sim-file #(select-keys % [:id :name :project-id])
|
||||
selected (get-in state [:dashboard-local :selected-files])
|
||||
xform (comp (map get-file)
|
||||
(map sim-file))]
|
||||
(->> (into #{} xform selected)
|
||||
(d/index-by :id))))
|
||||
st/state =))
|
||||
|
||||
;; ---- Workspace refs
|
||||
|
||||
|
@ -130,10 +151,11 @@
|
|||
|
||||
(def workspace-file
|
||||
(l/derived (fn [state]
|
||||
(when-let [file (:workspace-file state)]
|
||||
(let [file (:workspace-file state)
|
||||
data (:workspace-data state)]
|
||||
(-> file
|
||||
(dissoc :data)
|
||||
(assoc :pages (get-in file [:data :pages])))))
|
||||
(assoc :pages (:pages data)))))
|
||||
st/state =))
|
||||
|
||||
(def workspace-file-colors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue