diff --git a/src/components/create_playlist.rs b/src/components/create_playlist.rs index 67702ab..835927b 100644 --- a/src/components/create_playlist.rs +++ b/src/components/create_playlist.rs @@ -2,9 +2,11 @@ use leptos::*; use leptos_icons::*; use leptos::leptos_dom::*; use crate::api::playlists::create_playlist; +use crate::api::playlists::get_playlists; +use crate::models::Playlist; #[component] -pub fn CreatePlayList(closer: WriteSignal) -> impl IntoView { +pub fn CreatePlayList(closer: WriteSignal, set_playlists: WriteSignal>) -> impl IntoView { let (playlist_name, set_playlist_name) = create_signal("".to_string()); @@ -20,6 +22,13 @@ pub fn CreatePlayList(closer: WriteSignal) -> impl IntoView { log!("Playlist created successfully!"); closer.update(|value| *value = false); } + let playlists = get_playlists().await; + if let Err(err) = playlists { + // Handle the error here, e.g., log it or display to the user + log!("Error getting playlists: {:?}", err); + } else { + set_playlists.update(|value| *value = playlists.unwrap()); + } }) }; diff --git a/src/components/playlist.rs b/src/components/playlist.rs index 4ea6d1d..4874ed9 100644 --- a/src/components/playlist.rs +++ b/src/components/playlist.rs @@ -90,7 +90,7 @@ pub fn PlayListPopUp(playlist: Playlist, set_show_playlist: WriteSignal) -
    { - move || songs.get().iter().enumerate().map(|(index,song)| view! { + move || songs.get().iter().enumerate().map(|(_index,song)| view! { }).collect::>() } diff --git a/src/components/playlists.rs b/src/components/playlists.rs index 3df2966..54c2e30 100644 --- a/src/components/playlists.rs +++ b/src/components/playlists.rs @@ -11,7 +11,6 @@ pub fn Playlists() -> impl IntoView { let (playlists, set_playlists) = create_signal(vec![]); create_effect(move |_| { - spawn_local(async move { let playlists2 = get_playlists().await; if let Err(err) = playlists2 { @@ -38,12 +37,12 @@ pub fn Playlists() -> impl IntoView { when=move || create_playlist_open() fallback=move || view! {
    } > - +
      { - move || playlists.get().iter().enumerate().map(|(index,playlist)| view! { + move || playlists.get().iter().enumerate().map(|(_index,playlist)| view! { }).collect::>() }