fix pagination + add refresh button
All checks were successful
tests / fmt (push) Successful in 1m57s
tests / test (push) Successful in 2m7s
tests / clippy (push) Successful in 2m5s
tests / build (push) Successful in 2m11s
tests / pre-commit (push) Successful in 2m5s
deploy / release-image (push) Successful in 5m3s
All checks were successful
tests / fmt (push) Successful in 1m57s
tests / test (push) Successful in 2m7s
tests / clippy (push) Successful in 2m5s
tests / build (push) Successful in 2m11s
tests / pre-commit (push) Successful in 2m5s
deploy / release-image (push) Successful in 5m3s
This commit is contained in:
@@ -59,7 +59,6 @@ async fn get_tracks(
|
||||
if stderr.contains("YouTube said: The playlist does not exist.") {
|
||||
return Err("YouTube said: The playlist does not exist.".into());
|
||||
}
|
||||
return Err(stderr.into());
|
||||
}
|
||||
return Err("No tracks found".into());
|
||||
}
|
||||
|
||||
@@ -70,9 +70,6 @@ pub(crate) async fn build_queue_embeds(queue: &[TrackHandle], page: usize) -> Ve
|
||||
}
|
||||
|
||||
pub(crate) fn build_action_row(page: usize, max_pages: usize) -> Vec<Component> {
|
||||
if max_pages == 0 {
|
||||
return Vec::new();
|
||||
}
|
||||
vec![Component::ActionRow(ActionRow {
|
||||
components: vec![
|
||||
Component::Button(Button {
|
||||
@@ -85,6 +82,16 @@ pub(crate) fn build_action_row(page: usize, max_pages: usize) -> Vec<Component>
|
||||
url: None,
|
||||
disabled: page == 0,
|
||||
}),
|
||||
Component::Button(Button {
|
||||
custom_id: Some(format!("page:{}", page)),
|
||||
style: ButtonStyle::Primary,
|
||||
label: Some("Refresh".to_string()),
|
||||
emoji: Some(ReactionType::Unicode {
|
||||
name: "🔄".to_string(),
|
||||
}),
|
||||
url: None,
|
||||
disabled: false,
|
||||
}),
|
||||
Component::Button(Button {
|
||||
custom_id: Some(format!("page:{}", page + 1)),
|
||||
style: ButtonStyle::Primary,
|
||||
|
||||
@@ -147,8 +147,10 @@ impl Handler {
|
||||
let call = call_lock.lock().await;
|
||||
queue = call.queue().current_queue();
|
||||
}
|
||||
let n_pages = queue.len() / TRACKS_PER_PAGE;
|
||||
let page = page.min(n_pages).max(0);
|
||||
let embeds = build_queue_embeds(&queue, page).await;
|
||||
let action_row = build_action_row(page, queue.len() / TRACKS_PER_PAGE);
|
||||
let action_row = build_action_row(page, n_pages);
|
||||
|
||||
let interaction_response_data = InteractionResponseDataBuilder::new()
|
||||
.embeds(embeds)
|
||||
|
||||
Reference in New Issue
Block a user