From d8bf35e4b9c1fa3e9a0ac6fd3aad37a054e36c09 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Fri, 19 Apr 2024 15:50:05 +0200 Subject: feat: add remove from media queue feature --- src/frontend/tubo/events.cljs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/frontend') diff --git a/src/frontend/tubo/events.cljs b/src/frontend/tubo/events.cljs index a989dcc..da0657b 100644 --- a/src/frontend/tubo/events.cljs +++ b/src/frontend/tubo/events.cljs @@ -350,6 +350,19 @@ {:db updated-db :store (assoc store :media-queue (:media-queue updated-db))}))) +(rf/reg-event-fx + ::remove-from-media-queue + [(rf/inject-cofx :store)] + (fn [{:keys [db store]} [_ pos]] + (let [updated-db (update db :media-queue #(into (subvec % 0 pos) (subvec % (inc pos))))] + {:db updated-db + :store (assoc store :media-queue (:media-queue updated-db)) + :fx (if (and (= pos (:media-queue-pos db)) (not (= (count (:media-queue updated-db)) 0))) + [[:dispatch [::change-media-queue-pos pos]]] + (if (= (count (:media-queue updated-db)) 0) + [[:dispatch [::dispose-audio-player]] + [:dispatch [::show-media-queue false]]]))}))) + (rf/reg-event-fx ::change-media-queue-pos [(rf/inject-cofx :store)] -- cgit v1.2.3