Add liked songs page

This commit is contained in:
2025-05-06 03:17:35 +00:00
parent d2aebde562
commit f61507b197
3 changed files with 41 additions and 0 deletions

View File

@ -5,6 +5,7 @@ use crate::components::queue::Queue;
use crate::pages::album::*;
use crate::pages::artist::*;
use crate::pages::dashboard::*;
use crate::pages::liked_songs::*;
use crate::pages::login::*;
use crate::pages::playlist::*;
use crate::pages::profile::*;
@ -75,6 +76,7 @@ pub fn App() -> impl IntoView {
<Route path=path!("artist/:id") view=ArtistPage />
<Route path=path!("song/:id") view=SongPage />
<Route path=path!("playlist/:id") view=PlaylistPage />
<Route path=path!("liked") view=LikedSongsPage />
</ParentRoute>
<Route path=path!("/login") view=Login />
<Route path=path!("/signup") view=Signup />

38
src/pages/liked_songs.rs Normal file
View File

@ -0,0 +1,38 @@
use crate::components::error::*;
use crate::components::loading::*;
use crate::components::song_list::*;
use leptos::either::*;
use leptos::prelude::*;
use crate::api::profile::get_liked_songs;
#[component]
pub fn LikedSongsPage() -> impl IntoView {
let liked_songs = Resource::new(|| (), |_| get_liked_songs());
view! {
<h1 class="text-4xl">"Liked Songs"</h1>
<Transition
fallback=move || view! { <LoadingPage /> }
>
{move || liked_songs.get().map(|songs| {
match songs {
Ok(songs) => {
Either::Left(view! {
<p class="text-neutral-500">{songs.len()} " liked songs"</p>
<SongList songs />
})
},
Err(e) => {
Either::Right(view! {
<Error<String>
title="Error loading liked songs"
error=e.to_string()
/>
})
}
}
})}
</Transition>
}
}

View File

@ -1,6 +1,7 @@
pub mod album;
pub mod artist;
pub mod dashboard;
pub mod liked_songs;
pub mod login;
pub mod playlist;
pub mod profile;