From 2d2cbd772dd025312fc4fe2e70ff36241fc9cf7f Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Tue, 4 Jun 2024 14:14:21 +0200 Subject: fix: fix enqueueing logic --- src/frontend/tubo/queue/events.cljs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src') 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)}))) -- cgit v1.2.3