aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/tau/events.cljs
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2023-01-03 15:46:32 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2023-01-03 15:46:32 +0100
commitfe81ccdd9a3d2e3f2654be20f896e9ee6d7c833d (patch)
tree379602a8152579cad7367be71e4850a58d89c9ac /src/frontend/tau/events.cljs
parentf0577537daaf75e8da136bc2a1f303c225b47754 (diff)
feat(frontend): Add support for stream format selection
Diffstat (limited to 'src/frontend/tau/events.cljs')
-rw-r--r--src/frontend/tau/events.cljs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/frontend/tau/events.cljs b/src/frontend/tau/events.cljs
index 12404dc..dace6f5 100644
--- a/src/frontend/tau/events.cljs
+++ b/src/frontend/tau/events.cljs
@@ -309,11 +309,12 @@
{:nextPage (js/encodeURIComponent next-page-url)})
:db (assoc db :show-pagination-loading true)))))
-(rf/reg-event-db
+(rf/reg-event-fx
::load-stream
- (fn [db [_ res]]
- (assoc db :stream (js->clj res :keywordize-keys true)
- :show-page-loading false)))
+ (fn [{:keys [db]} [_ res]]
+ {:db (assoc db :stream (js->clj res :keywordize-keys true)
+ :show-page-loading false)
+ :fx [[:dispatch [::change-stream-format nil]]]}))
(rf/reg-event-fx
::get-stream
@@ -324,6 +325,16 @@
:db (assoc db :show-page-loading true))))
(rf/reg-event-db
+ ::change-stream-format
+ (fn [{:keys [stream] :as db} [_ format-id]]
+ (let [{:keys [audio-streams video-streams]} stream]
+ (if format-id
+ (assoc db :stream-format
+ (first (filter #(= format-id (:id %)) (apply conj audio-streams video-streams))))
+ (assoc db :stream-format (-> (if (empty? video-streams) audio-streams video-streams)
+ last))))))
+
+(rf/reg-event-db
::load-channel
(fn [db [_ res]]
(assoc db :channel (js->clj res :keywordize-keys true)