Added the watch and scheduler systems
This commit is contained in:
@@ -145,6 +145,52 @@ pub fn artist_page(props: &Props) -> Html {
|
||||
}
|
||||
};
|
||||
|
||||
let monitor_btn = {
|
||||
// Only show monitor toggle for artists that have a local DB ID (> 0)
|
||||
let artist_id_num = d.artist.id;
|
||||
let is_monitored = d.monitored;
|
||||
if artist_id_num > 0 {
|
||||
let message = message.clone();
|
||||
let error = error.clone();
|
||||
let fetch = fetch.clone();
|
||||
let artist_id = id.clone();
|
||||
let label = if is_monitored { "Unmonitor" } else { "Monitor" };
|
||||
let btn_class = if is_monitored {
|
||||
"btn btn-sm btn-secondary"
|
||||
} else {
|
||||
"btn btn-sm btn-primary"
|
||||
};
|
||||
html! {
|
||||
<button class={btn_class}
|
||||
onclick={Callback::from(move |_: MouseEvent| {
|
||||
let new_state = !is_monitored;
|
||||
let message = message.clone();
|
||||
let error = error.clone();
|
||||
let fetch = fetch.clone();
|
||||
let artist_id = artist_id.clone();
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
match api::set_artist_monitored(artist_id_num, new_state).await {
|
||||
Ok(_) => {
|
||||
let msg = if new_state {
|
||||
"Monitoring enabled -- new releases will be auto-watched"
|
||||
} else {
|
||||
"Monitoring disabled"
|
||||
};
|
||||
message.set(Some(msg.to_string()));
|
||||
fetch.emit(artist_id);
|
||||
}
|
||||
Err(e) => error.set(Some(e.0)),
|
||||
}
|
||||
});
|
||||
})}>
|
||||
{ label }
|
||||
</button>
|
||||
}
|
||||
} else {
|
||||
html! {}
|
||||
}
|
||||
};
|
||||
|
||||
html! {
|
||||
<div>
|
||||
if let Some(ref banner) = d.artist_banner {
|
||||
@@ -158,7 +204,12 @@ pub fn artist_page(props: &Props) -> Html {
|
||||
<img class="artist-photo" src={photo.clone()} loading="lazy" />
|
||||
}
|
||||
<div>
|
||||
<h2>{ &d.artist.name }</h2>
|
||||
<h2>
|
||||
{ &d.artist.name }
|
||||
if d.monitored {
|
||||
<span class="badge badge-success" style="margin-left: 0.5rem; font-size: 0.7em; vertical-align: middle;">{ "Monitored" }</span>
|
||||
}
|
||||
</h2>
|
||||
if let Some(ref info) = d.artist_info {
|
||||
<div class="artist-meta">
|
||||
if let Some(ref country) = info.country {
|
||||
@@ -195,7 +246,10 @@ pub fn artist_page(props: &Props) -> Html {
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
{ watch_all_btn }
|
||||
<div class="flex gap-1">
|
||||
{ watch_all_btn }
|
||||
{ monitor_btn }
|
||||
</div>
|
||||
</div>
|
||||
if let Some(ref bio) = d.artist_bio {
|
||||
<p class="artist-bio text-sm">{ bio }</p>
|
||||
|
||||
Reference in New Issue
Block a user