From 8297472635e71c3ec38b21fbc1a0678bd8f00828 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 19 Jun 2021 22:49:49 +0900 Subject: [PATCH] Improve 1-page cases --- youmubot-prelude/src/pagination.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/youmubot-prelude/src/pagination.rs b/youmubot-prelude/src/pagination.rs index c9595bd..488f64f 100644 --- a/youmubot-prelude/src/pagination.rs +++ b/youmubot-prelude/src/pagination.rs @@ -102,6 +102,12 @@ async fn paginate_with_first_message( mut message: Message, timeout: std::time::Duration, ) -> Result<()> { + pager.prerender(&ctx, &mut message).await?; + pager.render(0, ctx, &mut message).await?; + // Just quit if there is only one page + if pager.len().filter(|&v| v == 1).is_some() { + return Ok(()); + } // React to the message let large_count = pager.len().filter(|&p| p > 10).is_some(); if large_count { @@ -120,8 +126,6 @@ async fn paginate_with_first_message( .react(&ctx, ReactionType::try_from(FAST_FORWARD)?) .await?; } - pager.prerender(&ctx, &mut message).await?; - pager.render(0, ctx, &mut message).await?; // Build a reaction collector let mut reaction_collector = message.await_reactions(&ctx).removed(true).await; let mut page = 0;