aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2024-02-18 17:07:26 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2024-02-18 17:07:26 +0100
commit0d8ebac0ada2def30fd2fe79807ea18a4de7ef4c (patch)
treeda00455eb98db085ab58f2fd80355bc6f63fe247 /src/frontend
parent62a9b030c457a9bcc4736fafff17f4126edf4f95 (diff)
feat(frontend): add utils for retrieving service info
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/tubo/subs.cljs17
-rw-r--r--src/frontend/tubo/util.cljs18
2 files changed, 22 insertions, 13 deletions
diff --git a/src/frontend/tubo/subs.cljs b/src/frontend/tubo/subs.cljs
index b2f6ead..a4f84f2 100644
--- a/src/frontend/tubo/subs.cljs
+++ b/src/frontend/tubo/subs.cljs
@@ -1,7 +1,8 @@
(ns tubo.subs
(:require
[reagent.core :as r]
- [re-frame.core :as rf]))
+ [re-frame.core :as rf]
+ [tubo.util :as util]))
(defonce !is-window-visible
(let [a (r/atom true)]
@@ -100,24 +101,14 @@
(fn [_]
(rf/subscribe [:service-id]))
(fn [id _]
- (case id
- 0 "#cc0000"
- 1 "#ff7700"
- 2 "#333333"
- 3 "#F2690D"
- 4 "#629aa9")))
+ (util/get-service-color id)))
(rf/reg-sub
:service-name
(fn [_]
(rf/subscribe [:service-id]))
(fn [id _]
- (case id
- 0 "YouTube"
- 1 "SoundCloud"
- 2 "media.ccc.de"
- 3 "PeerTube"
- 4 "Bandcamp")))
+ (util/get-service-name id)))
(rf/reg-sub
:services
diff --git a/src/frontend/tubo/util.cljs b/src/frontend/tubo/util.cljs
index ea42ab6..7244106 100644
--- a/src/frontend/tubo/util.cljs
+++ b/src/frontend/tubo/util.cljs
@@ -2,6 +2,24 @@
(:require
["timeago.js" :as timeago]))
+(defn get-service-color
+ [id]
+ (case id
+ 0 "#cc0000"
+ 1 "#ff7700"
+ 2 "#333333"
+ 3 "#F2690D"
+ 4 "#629aa9"))
+
+(defn get-service-name
+ [id]
+ (case id
+ 0 "YouTube"
+ 1 "SoundCloud"
+ 2 "media.ccc.de"
+ 3 "PeerTube"
+ 4 "Bandcamp"))
+
(defn format-date-string
[date]
(-> date