From ed15406f518b0cdbe2e5cd82e2bc278f4f1af4ef Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 10 Mar 2025 15:02:16 +0100 Subject: [PATCH] Do rendering only once without pagination buttons, if there is only one page to display --- youmubot-prelude/src/pagination.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/youmubot-prelude/src/pagination.rs b/youmubot-prelude/src/pagination.rs index 19d0808..f302bad 100644 --- a/youmubot-prelude/src/pagination.rs +++ b/youmubot-prelude/src/pagination.rs @@ -251,14 +251,18 @@ pub async fn paginate_with_first_message( mut message: impl CanEdit, timeout: std::time::Duration, ) -> Result<()> { + // Just quit if there is only one page + if pager.len().filter(|&v| v == 1).is_some() { + do_render_with_btns(&mut pager, 0, &mut message, vec![]) + .await + .pls_ok(); + return Ok(()); + } + let msg_id = message.get_message().await?.id; let recv = crate::InteractionCollector::create(ctx, msg_id).await?; do_render(&mut pager, 0, &mut message).await?; - // Just quit if there is only one page - if pager.len().filter(|&v| v == 1).is_some() { - return Ok(()); - } let mut page = 0; // Loop the handler function.