From 0d8ebac0ada2def30fd2fe79807ea18a4de7ef4c Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Sun, 18 Feb 2024 17:07:26 +0100 Subject: feat(frontend): add utils for retrieving service info --- src/frontend/tubo/subs.cljs | 17 ++++------------- src/frontend/tubo/util.cljs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 13 deletions(-) (limited to 'src/frontend') 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 -- cgit v1.2.3