Lots of fixes for artist detail page and track management

This commit is contained in:
Connor Johnstone
2026-03-18 13:44:49 -04:00
parent 2314346925
commit a268ec4e56
12 changed files with 889 additions and 80 deletions

View File

@@ -2,12 +2,13 @@ use yew::prelude::*;
use yew_router::prelude::*;
use crate::api;
use crate::components::watch_indicator::WatchIndicator;
use crate::pages::Route;
use crate::types::Artist;
use crate::types::ArtistListItem;
#[function_component(LibraryPage)]
pub fn library_page() -> Html {
let artists = use_state(|| None::<Vec<Artist>>);
let artists = use_state(|| None::<Vec<ArtistListItem>>);
let error = use_state(|| None::<String>);
{
@@ -15,7 +16,7 @@ pub fn library_page() -> Html {
let error = error.clone();
use_effect_with((), move |_| {
wasm_bindgen_futures::spawn_local(async move {
match api::list_artists(100, 0).await {
match api::list_artists(200, 0).await {
Ok(a) => artists.set(Some(a)),
Err(e) => error.set(Some(e.0)),
}
@@ -43,17 +44,30 @@ pub fn library_page() -> Html {
} else {
<table>
<thead>
<tr><th>{ "Name" }</th><th>{ "MusicBrainz ID" }</th></tr>
<tr>
<th>{ "Name" }</th>
<th>{ "Status" }</th>
</tr>
</thead>
<tbody>
{ for artists.iter().map(|a| html! {
<tr>
<td>
<Link<Route> to={Route::Artist { id: a.id }}>
<Link<Route> to={Route::Artist { id: a.id.to_string() }}>
{ &a.name }
</Link<Route>>
</td>
<td class="text-muted text-sm">{ a.musicbrainz_id.as_deref().unwrap_or("") }</td>
<td>
if a.total_items > 0 {
<span class="text-sm" style={
if a.total_owned == a.total_items { "color: var(--success);" }
else if a.total_owned > 0 { "color: var(--warning);" }
else { "color: var(--accent);" }
}>
{ format!("{}/{} owned", a.total_owned, a.total_items) }
</span>
}
</td>
</tr>
})}
</tbody>