diff options
-rw-r--r-- | src/frontend/tubo/events.cljs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/frontend/tubo/events.cljs b/src/frontend/tubo/events.cljs index c4086ab..2c21dae 100644 --- a/src/frontend/tubo/events.cljs +++ b/src/frontend/tubo/events.cljs @@ -238,13 +238,17 @@ (rf/reg-event-fx ::change-media-queue-pos [(rf/inject-cofx :store)] - (fn [{:keys [db store]} [_ idx]] - (let [stream (get (:media-queue db) idx)] - {:db (-> db - (assoc :media-queue-pos idx) - (assoc-in [:media-queue idx :stream] "")) - :store (assoc store :media-queue-pos idx) - :fx [[:dispatch [::fetch-audio-player-stream (:url stream) idx]]]}))) + (fn [{:keys [db store]} [_ i]] + (let [idx (if (< i (count (:media-queue db))) + i + (when (= (:loop-playback db) :playlist) 0)) + stream (get (:media-queue db) idx)] + (when stream + {:db (-> db + (assoc :media-queue-pos idx) + (assoc-in [:media-queue idx :stream] "")) + :store (assoc store :media-queue-pos idx) + :fx [[:dispatch [::fetch-audio-player-stream (:url stream) idx true]]]})))) (rf/reg-event-fx ::change-media-queue-stream |