From ffa3639da047243c0bb333602f3118bf92d0797e Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Mon, 22 Jan 2024 01:02:57 +0100 Subject: feat(frontend): use general loop playback state --- src/frontend/tubo/components/audio_player.cljs | 4 +--- src/frontend/tubo/events.cljs | 15 +++++++++------ src/frontend/tubo/subs.cljs | 9 ++------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/frontend/tubo/components/audio_player.cljs b/src/frontend/tubo/components/audio_player.cljs index 4ecf9c8..d344d41 100644 --- a/src/frontend/tubo/components/audio_player.cljs +++ b/src/frontend/tubo/components/audio_player.cljs @@ -19,9 +19,7 @@ show-audio-player? @(rf/subscribe [:show-audio-player]) show-audio-player-loading? @(rf/subscribe [:show-audio-player-loading]) show-media-queue? @(rf/subscribe [:show-media-queue]) - is-window-visible @(rf/subscribe [:is-window-visible]) - loop-file? @(rf/subscribe [:loop-file]) - loop-playlist? @(rf/subscribe [:loop-playlist]) + loop-playback @(rf/subscribe [:loop-playback]) volume-level @(rf/subscribe [:volume-level]) muted? @(rf/subscribe [:muted]) !elapsed-time @(rf/subscribe [:elapsed-time]) diff --git a/src/frontend/tubo/events.cljs b/src/frontend/tubo/events.cljs index ae14b1b..7b2690a 100644 --- a/src/frontend/tubo/events.cljs +++ b/src/frontend/tubo/events.cljs @@ -15,15 +15,14 @@ (fn [{:keys [store]} _] (let [{:keys [current-theme show-comments show-related show-description media-queue media-queue-pos show-audio-player - loop-file loop-playlist volume-level muted bookmarks]} store] + loop-playback volume-level muted bookmarks]} store] {:db {:search-query "" :service-id 0 :stream {} :search-results [] :services [] - :loop-file (if (nil? loop-file) false loop-file) - :loop-playlist (if (nil? loop-playlist) true loop-playlist) + :loop-playback (if (nil? loop-playback) :playlist loop-playback) :media-queue (if (nil? media-queue) [] media-queue) :media-queue-pos (if (nil? media-queue-pos) 0 media-queue-pos) :volume-level (if (nil? volume-level) 100 volume-level) @@ -114,11 +113,15 @@ ::player-mute {:player player :muted? (not (:muted db))}})) (rf/reg-event-fx - ::toggle-loop-playlist + ::toggle-loop-playback [(rf/inject-cofx :store)] (fn [{:keys [db store]} _] - {:db (assoc db :loop-playlist (not (:loop-playlist db))) - :store (assoc store :loop-playlist (not (:loop-playlist store)))})) + (let [loop-state (case (:loop-playback db) + :stream :playlist + :playlist false + :stream)] + {:db (assoc db :loop-playback loop-state) + :store (assoc store :loop-playback loop-state)}))) (rf/reg-event-fx ::navigated diff --git a/src/frontend/tubo/subs.cljs b/src/frontend/tubo/subs.cljs index b046075..209b949 100644 --- a/src/frontend/tubo/subs.cljs +++ b/src/frontend/tubo/subs.cljs @@ -202,11 +202,6 @@ (:settings db))) (rf/reg-sub - :loop-file + :loop-playback (fn [db _] - (:loop-file db))) - -(rf/reg-sub - :loop-playlist - (fn [db _] - (:loop-playlist db))) + (:loop-playback db))) -- cgit v1.2.3