diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-01-22 01:12:25 +0100 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-01-22 01:12:25 +0100 |
commit | c29e709decfee4d7535ed3affb271472cc7ed053 (patch) | |
tree | 40ec8917564cb5befb627a8bfecb605565f64517 /src/frontend | |
parent | b9a2945b6bae73a34662cf17c66527b12e0ee402 (diff) |
feat(frontend): add media queue position guard at event level
Diffstat (limited to 'src/frontend')
-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 |