mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 08:06:12 +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]
|
||||
(let [origin-project (get-in state [:dashboard-files (first ids) :project-id])]
|
||||
(-> state
|
||||
(d/update-in-when [:dashboard-projects origin-project :count] #(- % (count ids)))
|
||||
(d/update-in-when [:dashboard-projects project-id :count] #(+ % (count ids))))))
|
||||
(d/update-in-when [:dashboard-projects origin-project] update :count #(- % (count ids)))
|
||||
(d/update-in-when [:dashboard-projects project-id] update :count #(+ % (count ids))))))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
|
|
|
@ -227,25 +227,31 @@
|
|||
[{:keys [team projects project section search-term profile] :as props}]
|
||||
(let [container (mf/use-ref)
|
||||
content-width (mf/use-state 0)
|
||||
|
||||
default-project-id
|
||||
(mf/with-memo [projects]
|
||||
(->> (vals projects)
|
||||
(d/seek :is-default)
|
||||
(:id))
|
||||
(:id)))
|
||||
|
||||
on-resize
|
||||
(mf/use-fn
|
||||
(fn [_]
|
||||
(let [dom (mf/ref-val container)
|
||||
width (obj/get dom "clientWidth")]
|
||||
(reset! content-width width)))]
|
||||
(reset! content-width width))))
|
||||
|
||||
(mf/use-effect
|
||||
#(let [key1 (events/listen js/window "resize" on-resize)]
|
||||
(fn []
|
||||
(events/unlistenByKey key1))))
|
||||
clear-selected-fn
|
||||
(mf/use-fn
|
||||
#(st/emit! (dd/clear-selected-files)))]
|
||||
|
||||
(mf/with-effect []
|
||||
(let [key1 (events/listen js/window "resize" on-resize)]
|
||||
#(events/unlistenByKey key1)))
|
||||
|
||||
(mf/use-effect on-resize)
|
||||
|
||||
[:div.dashboard-content {:on-click #(st/emit! (dd/clear-selected-files))
|
||||
:ref container}
|
||||
[:div.dashboard-content {:on-click clear-selected-fn :ref container}
|
||||
(case section
|
||||
:dashboard-projects
|
||||
[:*
|
||||
|
@ -280,8 +286,7 @@
|
|||
:search-term search-term}]
|
||||
|
||||
:dashboard-libraries
|
||||
[*
|
||||
[:& libraries-page {:team team}]]
|
||||
[:& libraries-page {:team team}]
|
||||
|
||||
:dashboard-team-members
|
||||
[:& team-members-page {:team team :profile profile}]
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
|
||||
on-move
|
||||
(fn [team-id project-id]
|
||||
(let [params {:ids (set (map :id files))
|
||||
(let [params {:ids (into #{} (map :id) files)
|
||||
:project-id project-id}]
|
||||
(fn []
|
||||
(st/emit! (dd/move-files
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue