mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
🐛 Fix some issues on recent files loading.
This commit is contained in:
parent
1ff9b24818
commit
77ab0706be
3 changed files with 32 additions and 34 deletions
|
@ -1254,7 +1254,7 @@
|
||||||
(ptk/reify ::go-to-dashboard
|
(ptk/reify ::go-to-dashboard
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state stream]
|
||||||
(let [team-id (or team-id (get-in state [:workspace-project :team-id]))]
|
(when-let [team-id (or team-id (:current-team-id state))]
|
||||||
(rx/of ::dwp/force-persist
|
(rx/of ::dwp/force-persist
|
||||||
(rt/nav :dashboard-projects {:team-id team-id})))))))
|
(rt/nav :dashboard-projects {:team-id team-id})))))))
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.messages :as dm]
|
[app.main.data.messages :as dm]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.refs :as refs]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.context-menu :refer [context-menu]]
|
[app.main.ui.components.context-menu :refer [context-menu]]
|
||||||
|
@ -28,7 +29,8 @@
|
||||||
left (or left 0)
|
left (or left 0)
|
||||||
|
|
||||||
current-team-id (mf/use-ctx ctx/current-team-id)
|
current-team-id (mf/use-ctx ctx/current-team-id)
|
||||||
teams (mf/use-state nil)
|
teams (mf/deref refs/teams)
|
||||||
|
teams (-> teams (dissoc current-team-id) vals vec)
|
||||||
|
|
||||||
on-duplicate-success
|
on-duplicate-success
|
||||||
(fn [new-project]
|
(fn [new-project]
|
||||||
|
@ -71,27 +73,19 @@
|
||||||
:accept-label (tr "modals.delete-project-confirm.accept")
|
:accept-label (tr "modals.delete-project-confirm.accept")
|
||||||
:on-accept delete-fn}))]
|
:on-accept delete-fn}))]
|
||||||
|
|
||||||
(mf/use-effect
|
[:& context-menu {:on-close on-menu-close
|
||||||
(fn []
|
:show show?
|
||||||
(->> (rp/query! :teams)
|
:fixed? (or (not= top 0) (not= left 0))
|
||||||
(rx/map (fn [teams]
|
:min-width? true
|
||||||
(into [] (remove #(= (:id %) current-team-id)) teams)))
|
:top top
|
||||||
(rx/subs #(reset! teams %)))))
|
:left left
|
||||||
|
:options [[(tr "labels.rename") on-edit]
|
||||||
(when @teams
|
[(tr "dashboard.duplicate") on-duplicate]
|
||||||
[:& context-menu {:on-close on-menu-close
|
[(tr "dashboard.pin-unpin") toggle-pin]
|
||||||
:show show?
|
(when (seq teams)
|
||||||
:fixed? (or (not= top 0) (not= left 0))
|
[(tr "dashboard.move-to") nil
|
||||||
:min-width? true
|
(for [team teams]
|
||||||
:top top
|
[(:name team) (on-move (:id team))])])
|
||||||
:left left
|
[:separator]
|
||||||
:options [[(tr "labels.rename") on-edit]
|
[(tr "labels.delete") on-delete]]}]))
|
||||||
[(tr "dashboard.duplicate") on-duplicate]
|
|
||||||
[(tr "dashboard.pin-unpin") toggle-pin]
|
|
||||||
(when (seq @teams)
|
|
||||||
[(tr "dashboard.move-to") nil
|
|
||||||
(for [team @teams]
|
|
||||||
[(:name team) (on-move (:id team))])])
|
|
||||||
[:separator]
|
|
||||||
[(tr "labels.delete") on-delete]]}])))
|
|
||||||
|
|
||||||
|
|
|
@ -115,12 +115,15 @@
|
||||||
(if (:is-default project)
|
(if (:is-default project)
|
||||||
(tr "labels.drafts")
|
(tr "labels.drafts")
|
||||||
(:name project))])
|
(:name project))])
|
||||||
[:& project-menu {:project project
|
|
||||||
:show? (:menu-open @local)
|
(when (:menu-open @local)
|
||||||
:left (:x (:menu-pos @local))
|
[:& project-menu {:project project
|
||||||
:top (:y (:menu-pos @local))
|
:show? (:menu-open @local)
|
||||||
:on-edit on-edit-open
|
:left (:x (:menu-pos @local))
|
||||||
:on-menu-close on-menu-close}]
|
:top (:y (:menu-pos @local))
|
||||||
|
:on-edit on-edit-open
|
||||||
|
:on-menu-close on-menu-close}])
|
||||||
|
|
||||||
[:span.info (str file-count " files")]
|
[:span.info (str file-count " files")]
|
||||||
(when (> file-count 0)
|
(when (> file-count 0)
|
||||||
(let [time (-> (:modified-at project)
|
(let [time (-> (:modified-at project)
|
||||||
|
@ -147,8 +150,7 @@
|
||||||
(let [projects (->> (vals projects)
|
(let [projects (->> (vals projects)
|
||||||
(sort-by :modified-at)
|
(sort-by :modified-at)
|
||||||
(reverse))
|
(reverse))
|
||||||
recent-map (mf/deref recent-files-ref)
|
recent-map (mf/deref recent-files-ref)]
|
||||||
files (vals recent-map)]
|
|
||||||
|
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps team)
|
(mf/deps team)
|
||||||
|
@ -167,7 +169,9 @@
|
||||||
[:& header]
|
[:& header]
|
||||||
[:section.dashboard-container
|
[:section.dashboard-container
|
||||||
(for [{:keys [id] :as project} projects]
|
(for [{:keys [id] :as project} projects]
|
||||||
(let [files (some->> files (filterv #(= id (:project-id %))))]
|
(let [files (when recent-map
|
||||||
|
(->> (vals recent-map)
|
||||||
|
(filterv #(= id (:project-id %)))))]
|
||||||
[:& project-item {:project project
|
[:& project-item {:project project
|
||||||
:files files
|
:files files
|
||||||
:first? (= project (first projects))
|
:first? (= project (first projects))
|
||||||
|
|
Loading…
Add table
Reference in a new issue