aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/tau/events.cljs
diff options
context:
space:
mode:
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)