💄 Minor cosmetic changes on recent files component.

This commit is contained in:
Andrey Antukh 2020-03-17 10:31:59 +01:00 committed by Alonso Torres
parent 383431ec6d
commit dca8971f06

View file

@ -42,36 +42,43 @@
;; --- Component: Drafts Page ;; --- Component: Drafts Page
(mf/defc recent-files-page (mf/defc recent-project
[{:keys [section team-id] :as props}] [{:keys [project files first? locale] :as props}]
(mf/use-effect (let [project-id (:id project)]
{:fn #(st/emit! (dsh/initialize-team team-id))
:deps (mf/deps team-id)})
(let [projects (mf/deref projects-ref)
recent-files (mf/deref recent-files-ref)
locale (i18n/use-locale)]
(if projects
[:section.recent-files-page
(for [project (vals projects)]
[:div.recent-files-row [:div.recent-files-row
{:key (:id project) {:class-name (when first? "first")}
:class-name (when (= project (first (vals projects))) "first")}
[:div.recent-files-row-title [:div.recent-files-row-title
[:h2.recent-files-row-title-name (:name project)] [:h2.recent-files-row-title-name (:name project)]
[:span.recent-files-row-title-info (str (:file-count project) " files")] [:span.recent-files-row-title-info (str (:file-count project) " files")]
(when (and recent-files (recent-files (:id project))) (when files
(let [time (-> (project :id) (let [time (-> (first files)
(recent-files) (:modified-at)
(first)
:modified-at
(dt/timeago {:locale locale}))] (dt/timeago {:locale locale}))]
[:span.recent-files-row-title-info (str ", " time)]))] [:span.recent-files-row-title-info (str ", " time)]))]
[:& grid {:id (:id project) [:& grid {:id (:id project)
:files (or :files (or files [])
(and recent-files (recent-files (:id project))) :hide-new? true}]]))
[])
:hide-new? true}]])]
[:section (mf/defc recent-files-page
[:p "empty"]]) [{:keys [section team-id] :as props}]
)) (mf/use-effect
{:fn #(st/emit! (dsh/initialize-recent team-id))
:deps (mf/deps team-id)})
(let [projects (->> (mf/deref projects-ref)
(vals)
(filter #(pos? (:file-count %)))
(sort-by :modified-at)
(reverse))
recent-files (mf/deref recent-files-ref)
locale (i18n/use-locale)]
(when (and projects recent-files)
[:section.recent-files-page
(for [project projects]
[:& recent-project {:project project
:locale locale
:key (:id project)
:files (get recent-files (:id project))
:first? (= project (first projects))}])])))