♻️ Refactor dashboard state management.

Mainly for performance, also affects backend endpoints.
This commit is contained in:
Andrey Antukh 2021-05-07 11:36:34 +02:00 committed by Andrés Moya
parent e7b3f12b71
commit c70bc5baff
23 changed files with 1110 additions and 1007 deletions

View file

@ -8,6 +8,7 @@
(:require
[app.main.data.dashboard :as dd]
[app.main.data.modal :as modal]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.ui.dashboard.grid :refer [grid]]
[app.main.ui.dashboard.inline-edition :refer [inline-edition]]
@ -77,15 +78,11 @@
[:a.btn-secondary.btn-small {:on-click on-create-clicked}
(tr "dashboard.new-file")]]))
(defn files-ref
[project-id]
(l/derived (l/in [:files project-id]) st/state))
(mf/defc files-section
[{:keys [project team] :as props}]
(let [files-ref (mf/use-memo (mf/deps (:id project)) #(files-ref (:id project)))
files-map (mf/deref files-ref)
(let [files-map (mf/deref refs/dashboard-files)
files (->> (vals files-map)
(filter #(= (:id project) (:project-id %)))
(sort-by :modified-at)
(reverse))]