0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

🐛 Fix some issues on recent files loading.

This commit is contained in:
Andrey Antukh 2021-05-20 16:55:57 +02:00
parent 1ff9b24818
commit 77ab0706be
3 changed files with 32 additions and 34 deletions

View file

@ -1254,7 +1254,7 @@
(ptk/reify ::go-to-dashboard
ptk/WatchEvent
(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
(rt/nav :dashboard-projects {:team-id team-id})))))))

View file

@ -9,6 +9,7 @@
[app.main.data.dashboard :as dd]
[app.main.data.messages :as dm]
[app.main.data.modal :as modal]
[app.main.refs :as refs]
[app.main.repo :as rp]
[app.main.store :as st]
[app.main.ui.components.context-menu :refer [context-menu]]
@ -28,7 +29,8 @@
left (or left 0)
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
(fn [new-project]
@ -71,14 +73,6 @@
:accept-label (tr "modals.delete-project-confirm.accept")
:on-accept delete-fn}))]
(mf/use-effect
(fn []
(->> (rp/query! :teams)
(rx/map (fn [teams]
(into [] (remove #(= (:id %) current-team-id)) teams)))
(rx/subs #(reset! teams %)))))
(when @teams
[:& context-menu {:on-close on-menu-close
:show show?
:fixed? (or (not= top 0) (not= left 0))
@ -88,10 +82,10 @@
:options [[(tr "labels.rename") on-edit]
[(tr "dashboard.duplicate") on-duplicate]
[(tr "dashboard.pin-unpin") toggle-pin]
(when (seq @teams)
(when (seq teams)
[(tr "dashboard.move-to") nil
(for [team @teams]
(for [team teams]
[(:name team) (on-move (:id team))])])
[:separator]
[(tr "labels.delete") on-delete]]}])))
[(tr "labels.delete") on-delete]]}]))

View file

@ -115,12 +115,15 @@
(if (:is-default project)
(tr "labels.drafts")
(:name project))])
(when (:menu-open @local)
[:& project-menu {:project project
:show? (:menu-open @local)
:left (:x (:menu-pos @local))
:top (:y (:menu-pos @local))
:on-edit on-edit-open
:on-menu-close on-menu-close}]
:on-menu-close on-menu-close}])
[:span.info (str file-count " files")]
(when (> file-count 0)
(let [time (-> (:modified-at project)
@ -147,8 +150,7 @@
(let [projects (->> (vals projects)
(sort-by :modified-at)
(reverse))
recent-map (mf/deref recent-files-ref)
files (vals recent-map)]
recent-map (mf/deref recent-files-ref)]
(mf/use-effect
(mf/deps team)
@ -167,7 +169,9 @@
[:& header]
[:section.dashboard-container
(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
:files files
:first? (= project (first projects))