From 8c282d4d24c156914390a87430d89fc5f2ac8ea8 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Thu, 19 Dec 2024 22:40:04 +0100 Subject: fix: fix start radio event effect handler --- src/frontend/tubo/bg_player/events.cljs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/frontend/tubo/bg_player/events.cljs b/src/frontend/tubo/bg_player/events.cljs index e7dcce8..da871d9 100644 --- a/src/frontend/tubo/bg_player/events.cljs +++ b/src/frontend/tubo/bg_player/events.cljs @@ -88,23 +88,22 @@ :bg-player/show [(rf/inject-cofx :store)] (fn [{:keys [db]} [_ stream notify?]] - (let [updated-db (update db :queue conj stream) - idx (.indexOf (:queue updated-db) stream)] - {:fx [(if (= (count (:queue db)) 0) - [:dispatch [:bg-player/fetch-stream (:url stream) idx true]] - [:dispatch [:queue/add stream notify?]])]}))) + {:fx [(if (= (count (:queue db)) 0) + [:dispatch [:bg-player/fetch-stream (:url stream) 0 true]] + [:dispatch [:queue/add stream notify?]])]})) (rf/reg-event-fx :bg-player/start-radio (fn [{:keys [db]} [_ stream]] - {:fx [[:dispatch [:bg-player/show stream]] - (when (not= (count (:queue db)) 0) - [:dispatch [:queue/change-pos (count (:queue db))]]) - [:dispatch [:bg-player/fetch-related-streams (:url stream)]] - [:dispatch - [:notifications/add - {:status-text "Started stream radio" - :failure :info}]]]})) + (let [updated-db (update db :queue conj stream) + idx (.lastIndexOf (:queue updated-db) stream)] + {:fx [[:dispatch [:queue/add stream]] + [:dispatch [:bg-player/fetch-stream (:url stream) idx true]] + [:dispatch [:bg-player/fetch-related-streams (:url stream)]] + [:dispatch + [:notifications/add + {:status-text "Started stream radio" + :failure :info}]]]}))) (rf/reg-event-fx :bg-player/switch-to-main -- cgit v1.2.3