aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2024-04-19 15:50:05 +0200
committerMiguel Ángel Moreno <mail@migalmoreno.com>2024-04-19 16:35:54 +0200
commitd8bf35e4b9c1fa3e9a0ac6fd3aad37a054e36c09 (patch)
tree777cd14c083b590faf2601690afda9c4dde1d50b /src
parent7de7af4e41fd57b514485efeb804d9efcaaa2cd6 (diff)
feat: add remove from media queue feature
Diffstat (limited to 'src')
-rw-r--r--src/frontend/tubo/events.cljs13
1 files changed, 13 insertions, 0 deletions
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
@@ -351,6 +351,19 @@
: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)]
(fn [{:keys [db store]} [_ i]]