aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/tubo/bg_player/events.cljs15
-rw-r--r--src/frontend/tubo/queue/events.cljs15
2 files changed, 17 insertions, 13 deletions
diff --git a/src/frontend/tubo/bg_player/events.cljs b/src/frontend/tubo/bg_player/events.cljs
index 297f0f0..c82b50e 100644
--- a/src/frontend/tubo/bg_player/events.cljs
+++ b/src/frontend/tubo/bg_player/events.cljs
@@ -86,19 +86,12 @@
(rf/reg-event-fx
:bg-player/show
[(rf/inject-cofx :store)]
- (fn [{:keys [db store]} [_ stream notify?]]
+ (fn [{:keys [db]} [_ stream notify?]]
(let [updated-db (update db :queue conj stream)
idx (.indexOf (:queue updated-db) stream)]
- {:db updated-db
- :store (assoc store :queue (:queue updated-db))
- :fx [[:dispatch
- [:bg-player/fetch-stream
- (:url stream) idx (= (count (:queue db)) 0)]]
- (when (and notify? (not (= (count (:queue db)) 0)))
- [:dispatch
- [:notifications/add
- {:status-text "Added stream to queue"
- :failure :info}]])]})))
+ {:fx [(if (= (count (:queue db)) 0)
+ [:dispatch [:bg-player/fetch-stream (:url stream) idx true]]
+ [:dispatch [:queue/add stream notify?]])]})))
(rf/reg-event-fx
:bg-player/start-radio
diff --git a/src/frontend/tubo/queue/events.cljs b/src/frontend/tubo/queue/events.cljs
index 2765af2..08bd9c0 100644
--- a/src/frontend/tubo/queue/events.cljs
+++ b/src/frontend/tubo/queue/events.cljs
@@ -3,6 +3,13 @@
[re-frame.core :as rf]
[vimsical.re-frame.cofx.inject :as inject]))
+(defn get-stream-metadata
+ [stream]
+ (select-keys stream
+ [:type :service-id :url :name :thumbnails :audio-streams
+ :video-streams :uploader-name :uploader-url :duration
+ :bookmark-id]))
+
(rf/reg-event-fx
:queue/show
(fn [{:keys [db]} [_ show?]]
@@ -36,7 +43,7 @@
:queue/add
[(rf/inject-cofx :store)]
(fn [{:keys [db store]} [_ stream notify?]]
- (let [updated-db (update db :queue conj stream)]
+ (let [updated-db (update db :queue conj (get-stream-metadata stream))]
{:db updated-db
:store (assoc store :queue (:queue updated-db))
:fx (if notify?
@@ -108,7 +115,11 @@
[(rf/inject-cofx :store)
(rf/inject-cofx ::inject/sub [:bg-player])]
(fn [{:keys [db store bg-player]} [_ stream idx]]
- (let [update-entry (fn [x] (update-in x [:queue idx] #(merge % stream)))]
+ (let [update-entry (fn [x]
+ (update-in
+ x
+ [:queue idx]
+ #(merge % (get-stream-metadata stream))))]
{:db (assoc (update-entry db) :queue/position idx)
:store (assoc (update-entry store) :queue/position idx)
:player/src {:player bg-player