Add fast forward pagination buttons to incidents command

This commit is contained in:
2025-08-23 02:15:40 -03:00
parent 679096a685
commit c5d699292f
2 changed files with 23 additions and 3 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ use crate::{
#[derive(Debug)] #[derive(Debug)]
pub struct ArrowIncidentButton { pub struct ArrowIncidentButton {
pub arrow: char, pub arrow: &'static str,
pub user_id: u64, pub user_id: u64,
pub go_to: Option<usize>, pub go_to: Option<usize>,
} }
+22 -2
View File
@@ -33,7 +33,15 @@ pub(super) async fn get_incident_page(
.embed(incident_embed(incident)) .embed(incident_embed(incident))
.component( .component(
ArrowIncidentButton { ArrowIncidentButton {
arrow: '<', arrow: "<<",
user_id,
go_to: if page_index > 0 { Some(0) } else { None },
},
1,
)
.component(
ArrowIncidentButton {
arrow: "<",
user_id, user_id,
go_to: if page_index > 0 { go_to: if page_index > 0 {
Some(page_index - 1) Some(page_index - 1)
@@ -52,11 +60,23 @@ pub(super) async fn get_incident_page(
) )
.component( .component(
ArrowIncidentButton { ArrowIncidentButton {
arrow: '>', arrow: ">",
user_id, user_id,
go_to: incidents.get(page_index + 1).map(|_| page_index + 1), go_to: incidents.get(page_index + 1).map(|_| page_index + 1),
}, },
1, 1,
)
.component(
ArrowIncidentButton {
arrow: ">>",
user_id,
go_to: if page_index + 1 < incidents.len() {
Some(incidents.len() - 1)
} else {
None
},
},
1,
); );
if incident.r#type == UserIncidentType::Ban { if incident.r#type == UserIncidentType::Ban {