diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-06-04 14:14:21 +0200 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-06-04 14:14:21 +0200 |
commit | 2d2cbd772dd025312fc4fe2e70ff36241fc9cf7f (patch) | |
tree | 507dd609020518252eb81f60ca1fec882d751c9b | |
parent | 30a03d4fbf43b0d02e969e912627b3b47e25c883 (diff) |
fix: fix enqueueing logic
-rw-r--r-- | src/frontend/tubo/queue/events.cljs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/frontend/tubo/queue/events.cljs b/src/frontend/tubo/queue/events.cljs index 974700a..b706452 100644 --- a/src/frontend/tubo/queue/events.cljs +++ b/src/frontend/tubo/queue/events.cljs @@ -69,17 +69,12 @@ (when (= (:loop-playback db) :playlist) 0)) stream (get (:queue db) idx)] (when stream - {:db (-> db - (assoc :player-ready false) - (assoc :queue-pos idx) - (assoc-in [:queue idx :stream] "")) - :store (assoc store :queue-pos idx) - :fx [[:dispatch [:player/fetch-stream (:url stream) idx true]]]})))) + {:fx [[:dispatch [:player/fetch-stream (:url stream) idx true]]]})))) (rf/reg-event-fx - :queue/change-stream-source + :queue/change-stream [(rf/inject-cofx :store)] - (fn [{:keys [db store]} [_ src idx]] - (let [update-entry #(assoc-in % [:queue idx :stream] src)] - {:db (update-entry db) - :store (update-entry store)}))) + (fn [{:keys [db store]} [_ stream idx]] + (let [update-entry (fn [x] (update-in x [:queue idx] #(merge % stream)))] + {:db (assoc (update-entry db) :queue-pos idx) + :store (assoc (update-entry store) :queue-pos idx)}))) |