1
0
Преглед на файлове

feat(frontend): rename date formatting utils

Miguel Ángel Moreno преди 1 година
родител
ревизия
c2cba71697
променени са 4 файла, в които са добавени 11 реда и са изтрити 8 реда
  1. 1 1
      src/frontend/tubo/components/comments.cljs
  2. 1 1
      src/frontend/tubo/components/items.cljs
  3. 8 1
      src/frontend/tubo/util.cljs
  4. 1 5
      src/frontend/tubo/views/stream.cljs

+ 1 - 1
src/frontend/tubo/components/comments.cljs

@@ -34,7 +34,7 @@
      [:p.break-words {:dangerouslySetInnerHTML {:__html text}}]]
     [:div..flex.items-center.my-2
      [:div.mr-4
-      [:p (util/format-date upload-date)]]
+      [:p (util/format-date-ago upload-date)]]
      (when (and like-count (> like-count 0))
        [:div.flex.items-center.my-2
         [:i.fa-solid.fa-thumbs-up.text-xs]

+ 1 - 1
src/frontend/tubo/components/items.cljs

@@ -59,7 +59,7 @@
         [:i.fa-solid.fa-video.text-xs]
         [:p.mx-2 (util/format-quantity stream-count)]])
      [:div.flex.my-1.justify-between
-      [:p (util/format-date upload-date)]
+      [:p (util/format-date-ago upload-date)]
       (when view-count
         [:div.flex.items-center.h-full.pl-2
          [:i.fa-solid.fa-eye.text-xs]

+ 8 - 1
src/frontend/tubo/util.cljs

@@ -2,7 +2,14 @@
   (:require
    ["timeago.js" :as timeago]))
 
-(defn format-date
+(defn format-date-string
+  [date]
+  (-> date
+      js/Date.parse
+      js/Date.
+      .toDateString))
+
+(defn format-date-ago
   [date]
   (if (-> date js/Date.parse js/isNaN)
     date

+ 1 - 5
src/frontend/tubo/views/stream.cljs

@@ -97,11 +97,7 @@
          (when upload-date
            [:div.sm:text-base.text-sm.mt-1.whitespace-nowrap
             [:i.fa-solid.fa-calendar]
-            [:span.ml-2
-             (-> upload-date
-                 js/Date.parse
-                 js/Date.
-                 .toDateString)]])]]
+            [:span.ml-2 (util/format-date-string upload-date)]])]]
        (when (and show-description? (not (empty? description)))
          [:div.py-3.flex.flex-wrap.min-w-full
           [:div {:dangerouslySetInnerHTML {:__html description}