From fbc57fd90e69bfd44036013aa1634e7b9defea40 Mon Sep 17 00:00:00 2001 From: ecco257 <72117210+ecco257@users.noreply.github.com> Date: Fri, 16 Feb 2024 17:34:45 -0500 Subject: [PATCH] Modify queue to only allow delete of upcoming songs --- src/queue.rs | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/queue.rs b/src/queue.rs index 1cf5f8d..2027169 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -1,7 +1,4 @@ use crate::playstatus::PlayStatus; -use crate::playbar::skip_to; -use crate::playbar::get_song_time_duration; -use crate::playbar::set_playing; use leptos::ev::MouseEvent; use leptos::leptos_dom::*; use leptos::*; @@ -10,24 +7,11 @@ use leptos_icons::BsIcon::*; const RM_BTN_SIZE: &str = "2rem"; -fn skip_to_next(status: RwSignal) { - - if let Some(duration) = get_song_time_duration(status) { - skip_to(status, duration.1); - set_playing(status, true); - } else { - error!("Unable to skip forward: Unable to get current duration"); - } -} - fn remove_song_fn(index: usize, status: RwSignal) { - // handle the case when index is 0 (i.e. the first song in the queue is removed) - // if the song is currently playing, skip to the next song if index == 0 { - log!("Remove Song from Queue: Song is currently playing, skipping to next song and adding to history"); - skip_to_next(status); + log!("Error: Trying to remove currently playing song (index 0) from queue"); } else { - log!("Remove Song from Queue: Song is not currently playing, no need to skip to next song, instead deleting song from queue and not adding to history"); + log!("Remove Song from Queue: Song is not currently playing, deleting song from queue and not adding to history"); status.update(|status| { status.queue.remove(index); }); @@ -74,9 +58,15 @@ pub fn Queue(status: RwSignal) -> impl IntoView { .map(|(index, song)| view! {
- + Playing

+ }> + +
}) .collect::>())