Attempt to fix playlist gen dropdown
This commit is contained in:
@@ -23,8 +23,9 @@ pub fn artist_page(props: &Props) -> Html {
|
|||||||
let top_songs_limit = use_state(|| 25usize);
|
let top_songs_limit = use_state(|| 25usize);
|
||||||
let watch_top_count = use_state(|| 10usize);
|
let watch_top_count = use_state(|| 10usize);
|
||||||
// Track top song status overrides — use Rc<RefCell> so async callbacks always see latest state
|
// Track top song status overrides — use Rc<RefCell> so async callbacks always see latest state
|
||||||
let top_song_overrides: Rc<std::cell::RefCell<std::collections::HashMap<usize, Option<String>>>> =
|
let top_song_overrides: Rc<
|
||||||
use_mut_ref(std::collections::HashMap::new);
|
std::cell::RefCell<std::collections::HashMap<usize, Option<String>>>,
|
||||||
|
> = use_mut_ref(std::collections::HashMap::new);
|
||||||
// Counter to force re-renders when overrides change
|
// Counter to force re-renders when overrides change
|
||||||
let overrides_version = use_state(|| 0u32);
|
let overrides_version = use_state(|| 0u32);
|
||||||
let id = props.id.clone();
|
let id = props.id.clone();
|
||||||
@@ -336,7 +337,9 @@ pub fn artist_page(props: &Props) -> Html {
|
|||||||
|
|
||||||
// Mark all as pending immediately
|
// Mark all as pending immediately
|
||||||
for (i, _, _) in &to_watch {
|
for (i, _, _) in &to_watch {
|
||||||
overrides.borrow_mut().insert(*i, Some("pending".to_string()));
|
overrides
|
||||||
|
.borrow_mut()
|
||||||
|
.insert(*i, Some("pending".to_string()));
|
||||||
}
|
}
|
||||||
version.set(*version + 1);
|
version.set(*version + 1);
|
||||||
|
|
||||||
@@ -346,7 +349,13 @@ pub fn artist_page(props: &Props) -> Html {
|
|||||||
let artist = artist.clone();
|
let artist = artist.clone();
|
||||||
wasm_bindgen_futures::spawn_local(async move {
|
wasm_bindgen_futures::spawn_local(async move {
|
||||||
for (i, name, mbid) in to_watch {
|
for (i, name, mbid) in to_watch {
|
||||||
let status = match api::watch_track(Some(&artist), &name, mbid.as_deref().unwrap_or("")).await {
|
let status = match api::watch_track(
|
||||||
|
Some(&artist),
|
||||||
|
&name,
|
||||||
|
mbid.as_deref().unwrap_or(""),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(resp) => resp.status,
|
Ok(resp) => resp.status,
|
||||||
Err(_) => "wanted".to_string(),
|
Err(_) => "wanted".to_string(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ pub fn playlists_page() -> Html {
|
|||||||
current.is_none()
|
current.is_none()
|
||||||
})
|
})
|
||||||
.filter(|a| !seeds_c.contains(&a.name))
|
.filter(|a| !seeds_c.contains(&a.name))
|
||||||
.take(15)
|
.take(50)
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
html! {
|
html! {
|
||||||
@@ -385,7 +385,7 @@ pub fn playlists_page() -> Html {
|
|||||||
let name = a.name.clone();
|
let name = a.name.clone();
|
||||||
let seeds = seeds.clone();
|
let seeds = seeds.clone();
|
||||||
let si = seed_input.clone();
|
let si = seed_input.clone();
|
||||||
let track_count = a.total_items;
|
let track_count = a.local_tracks;
|
||||||
html! {
|
html! {
|
||||||
<div class="autocomplete-item" onclick={Callback::from(move |_: MouseEvent| {
|
<div class="autocomplete-item" onclick={Callback::from(move |_: MouseEvent| {
|
||||||
let mut v = (*seeds).clone();
|
let mut v = (*seeds).clone();
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ pub struct ArtistListItem {
|
|||||||
pub total_watched: usize,
|
pub total_watched: usize,
|
||||||
pub total_owned: usize,
|
pub total_owned: usize,
|
||||||
pub total_items: usize,
|
pub total_items: usize,
|
||||||
|
#[serde(default)]
|
||||||
|
pub local_tracks: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ struct ArtistListItem {
|
|||||||
total_watched: usize,
|
total_watched: usize,
|
||||||
total_owned: usize,
|
total_owned: usize,
|
||||||
total_items: usize,
|
total_items: usize,
|
||||||
|
local_tracks: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
@@ -131,6 +132,10 @@ async fn list_artists(
|
|||||||
.collect::<std::collections::HashSet<_>>()
|
.collect::<std::collections::HashSet<_>>()
|
||||||
.len();
|
.len();
|
||||||
|
|
||||||
|
let local_tracks = queries::tracks::count_by_artist(state.db.conn(), a.id)
|
||||||
|
.await
|
||||||
|
.unwrap_or(0);
|
||||||
|
|
||||||
items.push(ArtistListItem {
|
items.push(ArtistListItem {
|
||||||
id: a.id,
|
id: a.id,
|
||||||
name: a.name.clone(),
|
name: a.name.clone(),
|
||||||
@@ -140,6 +145,7 @@ async fn list_artists(
|
|||||||
total_watched,
|
total_watched,
|
||||||
total_owned,
|
total_owned,
|
||||||
total_items,
|
total_items,
|
||||||
|
local_tracks,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user