mirror of
https://github.com/penpot/penpot.git
synced 2025-05-24 14:26:43 +02:00
✨ Add some minor performance improvements to dashboard components
This commit is contained in:
parent
35969e9f26
commit
bf3888585a
4 changed files with 32 additions and 27 deletions
|
@ -893,8 +893,8 @@
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [origin-project (get-in state [:dashboard-files (first ids) :project-id])]
|
(let [origin-project (get-in state [:dashboard-files (first ids) :project-id])]
|
||||||
(-> state
|
(-> state
|
||||||
(d/update-in-when [:dashboard-projects origin-project :count] #(- % (count ids)))
|
(d/update-in-when [:dashboard-projects origin-project] update :count #(- % (count ids)))
|
||||||
(d/update-in-when [:dashboard-projects project-id :count] #(+ % (count ids))))))
|
(d/update-in-when [:dashboard-projects project-id] update :count #(+ % (count ids))))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
|
|
|
@ -227,25 +227,31 @@
|
||||||
[{:keys [team projects project section search-term profile] :as props}]
|
[{:keys [team projects project section search-term profile] :as props}]
|
||||||
(let [container (mf/use-ref)
|
(let [container (mf/use-ref)
|
||||||
content-width (mf/use-state 0)
|
content-width (mf/use-state 0)
|
||||||
|
|
||||||
default-project-id
|
default-project-id
|
||||||
|
(mf/with-memo [projects]
|
||||||
(->> (vals projects)
|
(->> (vals projects)
|
||||||
(d/seek :is-default)
|
(d/seek :is-default)
|
||||||
(:id))
|
(:id)))
|
||||||
|
|
||||||
on-resize
|
on-resize
|
||||||
|
(mf/use-fn
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(let [dom (mf/ref-val container)
|
(let [dom (mf/ref-val container)
|
||||||
width (obj/get dom "clientWidth")]
|
width (obj/get dom "clientWidth")]
|
||||||
(reset! content-width width)))]
|
(reset! content-width width))))
|
||||||
|
|
||||||
(mf/use-effect
|
clear-selected-fn
|
||||||
#(let [key1 (events/listen js/window "resize" on-resize)]
|
(mf/use-fn
|
||||||
(fn []
|
#(st/emit! (dd/clear-selected-files)))]
|
||||||
(events/unlistenByKey key1))))
|
|
||||||
|
(mf/with-effect []
|
||||||
|
(let [key1 (events/listen js/window "resize" on-resize)]
|
||||||
|
#(events/unlistenByKey key1)))
|
||||||
|
|
||||||
(mf/use-effect on-resize)
|
(mf/use-effect on-resize)
|
||||||
|
|
||||||
[:div.dashboard-content {:on-click #(st/emit! (dd/clear-selected-files))
|
[:div.dashboard-content {:on-click clear-selected-fn :ref container}
|
||||||
:ref container}
|
|
||||||
(case section
|
(case section
|
||||||
:dashboard-projects
|
:dashboard-projects
|
||||||
[:*
|
[:*
|
||||||
|
@ -280,8 +286,7 @@
|
||||||
:search-term search-term}]
|
:search-term search-term}]
|
||||||
|
|
||||||
:dashboard-libraries
|
:dashboard-libraries
|
||||||
[*
|
[:& libraries-page {:team team}]
|
||||||
[:& libraries-page {:team team}]]
|
|
||||||
|
|
||||||
:dashboard-team-members
|
:dashboard-team-members
|
||||||
[:& team-members-page {:team team :profile profile}]
|
[:& team-members-page {:team team :profile profile}]
|
||||||
|
|
|
@ -131,7 +131,7 @@
|
||||||
|
|
||||||
on-move
|
on-move
|
||||||
(fn [team-id project-id]
|
(fn [team-id project-id]
|
||||||
(let [params {:ids (set (map :id files))
|
(let [params {:ids (into #{} (map :id) files)
|
||||||
:project-id project-id}]
|
:project-id project-id}]
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! (dd/move-files
|
(st/emit! (dd/move-files
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue