From 4a5ee917fba2be13faff30c05d51f8dda80f2c73 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Wed, 5 Jun 2024 01:47:27 +0200 Subject: fix: fix hiding background player after player disposal --- src/frontend/tubo/player/events.cljs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/frontend') diff --git a/src/frontend/tubo/player/events.cljs b/src/frontend/tubo/player/events.cljs index e32b4aa..c9fca56 100644 --- a/src/frontend/tubo/player/events.cljs +++ b/src/frontend/tubo/player/events.cljs @@ -162,6 +162,13 @@ :store (assoc store :muted value) :mute {:player player :muted? value}})) +(rf/reg-event-fx + :background-player/hide + [(rf/inject-cofx :store)] + (fn [{:keys [db store]} _] + {:db (assoc db :background-player/show false) + :store (assoc store :background-player/show false)})) + (rf/reg-event-fx :player/loop [(rf/inject-cofx :store)] @@ -180,13 +187,13 @@ (let [remove-entries (fn [elem] (-> elem - (assoc :background-player/show false) (assoc :queue []) (assoc :queue-pos 0)))] {:db (remove-entries db) :store (remove-entries store) :fx [[:dispatch [:background-player/pause true]] - [:dispatch [:background-player/seek 0]]]}))) + [:dispatch [:background-player/seek 0]] + [:dispatch [:background-player/hide]]]}))) (rf/reg-event-db :background-player/ready @@ -251,9 +258,9 @@ (fn [{:keys [db store player]} [_ idx play? res]] (let [stream-res (js->clj res :keywordize-keys true)] {:db (assoc db - :background-player/show (not (:main-player-show db)) + :background-player/show (not (:main-player/show db)) :background-player/loading false) - :store (assoc store :background-player/show (not (:main-player-show db))) + :store (assoc store :background-player/show (not (:main-player/show db))) :fx (apply conj [(when play? [:dispatch [:queue/change-stream stream-res idx]])] (when (and (:background-player/ready db) play?) [[:media-session-metadata -- cgit v1.2.3