|
|
@@ -20,43 +20,48 @@
|
|
|
[promesa.core :as p]
|
|
|
[reitit.frontend.easy :as rfe]
|
|
|
[rum.core :as rum]
|
|
|
- [logseq.common.path :as path]))
|
|
|
+ [logseq.common.path :as path]
|
|
|
+ [frontend.db.async :as db-async]))
|
|
|
|
|
|
(defn- get-path
|
|
|
[state]
|
|
|
(let [route-match (first (:rum/args state))]
|
|
|
(get-in route-match [:parameters :path :path])))
|
|
|
|
|
|
-(rum/defc files-all < rum/reactive
|
|
|
- []
|
|
|
- (when-let [current-repo (state/sub :git/current-repo)]
|
|
|
- (let [files (db/get-files current-repo) ; [[string]]
|
|
|
- files (sort-by first gstring/intAwareCompare files)
|
|
|
- mobile? (util/mobile?)]
|
|
|
- [:table.table-auto
|
|
|
- [:thead
|
|
|
- [:tr
|
|
|
- [:th (t :file/name)]
|
|
|
- (when-not mobile?
|
|
|
- [:th (t :file/last-modified-at)])
|
|
|
- (when-not mobile?
|
|
|
- [:th ""])]]
|
|
|
- [:tbody
|
|
|
- (for [[file modified-at] files]
|
|
|
- (let [file-id file]
|
|
|
- [:tr {:key file-id}
|
|
|
- [:td
|
|
|
- (let [href (if (common-config/draw? file)
|
|
|
- (rfe/href :draw nil {:file (string/replace file (str common-config/default-draw-directory "/") "")})
|
|
|
- (rfe/href :file {:path file-id}))]
|
|
|
- [:a {:href href}
|
|
|
- file])]
|
|
|
- (when-not mobile?
|
|
|
- [:td [:span.text-gray-500.text-sm
|
|
|
- (if (or (nil? modified-at) (zero? modified-at))
|
|
|
- (t :file/no-data)
|
|
|
- (date/get-date-time-string
|
|
|
- (t/to-default-time-zone (tc/to-date-time modified-at))))]])]))]])))
|
|
|
+(rum/defcs files-all < rum/reactive
|
|
|
+ {:init (fn [state]
|
|
|
+ (let [*files (atom nil)]
|
|
|
+ (p/let [result (db-async/<get-files (state/get-current-repo))]
|
|
|
+ (reset! *files result))
|
|
|
+ (assoc state ::files *files)))}
|
|
|
+ [state]
|
|
|
+ (let [files (rum/react (::files state))
|
|
|
+ files (sort-by first gstring/intAwareCompare files)
|
|
|
+ mobile? (util/mobile?)]
|
|
|
+ [:table.table-auto
|
|
|
+ [:thead
|
|
|
+ [:tr
|
|
|
+ [:th (t :file/name)]
|
|
|
+ (when-not mobile?
|
|
|
+ [:th (t :file/last-modified-at)])
|
|
|
+ (when-not mobile?
|
|
|
+ [:th ""])]]
|
|
|
+ [:tbody
|
|
|
+ (for [[file modified-at] files]
|
|
|
+ (let [file-id file]
|
|
|
+ [:tr {:key file-id}
|
|
|
+ [:td
|
|
|
+ (let [href (if (common-config/draw? file)
|
|
|
+ (rfe/href :draw nil {:file (string/replace file (str common-config/default-draw-directory "/") "")})
|
|
|
+ (rfe/href :file {:path file-id}))]
|
|
|
+ [:a {:href href}
|
|
|
+ file])]
|
|
|
+ (when-not mobile?
|
|
|
+ [:td [:span.text-gray-500.text-sm
|
|
|
+ (if (or (nil? modified-at) (zero? modified-at))
|
|
|
+ (t :file/no-data)
|
|
|
+ (date/get-date-time-string
|
|
|
+ (t/to-default-time-zone (tc/to-date-time modified-at))))]])]))]]))
|
|
|
|
|
|
(rum/defc files
|
|
|
[]
|