wip bump versions
This commit is contained in:
		@@ -1,8 +1,6 @@
 | 
			
		||||
// todo split pager out into a single struct
 | 
			
		||||
use chrono_tz::Tz;
 | 
			
		||||
use poise::serenity_prelude::{
 | 
			
		||||
    builder::CreateComponents, model::application::component::ButtonStyle,
 | 
			
		||||
};
 | 
			
		||||
use poise::serenity_prelude::{ButtonStyle, CreateActionRow, CreateButton};
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
use serde_repr::*;
 | 
			
		||||
 | 
			
		||||
@@ -11,7 +9,7 @@ use crate::{component_models::ComponentDataModel, models::reminder::look_flags::
 | 
			
		||||
pub trait Pager {
 | 
			
		||||
    fn next_page(&self, max_pages: usize) -> usize;
 | 
			
		||||
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize, comp: &mut CreateComponents);
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize) -> CreateActionRow;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Serialize_repr, Deserialize_repr)]
 | 
			
		||||
@@ -43,41 +41,33 @@ impl Pager for LookPager {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize, comp: &mut CreateComponents) {
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize) -> CreateActionRow {
 | 
			
		||||
        let next_page = self.next_page(max_pages);
 | 
			
		||||
 | 
			
		||||
        let (page_first, page_prev, page_refresh, page_next, page_last) =
 | 
			
		||||
            LookPager::buttons(self.flags, next_page, self.timezone);
 | 
			
		||||
 | 
			
		||||
        comp.create_action_row(|row| {
 | 
			
		||||
            row.create_button(|b| {
 | 
			
		||||
                b.label("⏮️")
 | 
			
		||||
                    .style(ButtonStyle::Primary)
 | 
			
		||||
                    .custom_id(page_first.to_custom_id())
 | 
			
		||||
                    .disabled(next_page == 0)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("◀️")
 | 
			
		||||
                    .style(ButtonStyle::Secondary)
 | 
			
		||||
                    .custom_id(page_prev.to_custom_id())
 | 
			
		||||
                    .disabled(next_page == 0)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("🔁").style(ButtonStyle::Secondary).custom_id(page_refresh.to_custom_id())
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("▶️")
 | 
			
		||||
                    .style(ButtonStyle::Secondary)
 | 
			
		||||
                    .custom_id(page_next.to_custom_id())
 | 
			
		||||
                    .disabled(next_page + 1 == max_pages)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("⏭️")
 | 
			
		||||
                    .style(ButtonStyle::Primary)
 | 
			
		||||
                    .custom_id(page_last.to_custom_id())
 | 
			
		||||
                    .disabled(next_page + 1 == max_pages)
 | 
			
		||||
            })
 | 
			
		||||
        });
 | 
			
		||||
        CreateActionRow::Buttons(vec![
 | 
			
		||||
            CreateButton::new(page_first.to_custom_id())
 | 
			
		||||
                .label("⏮️")
 | 
			
		||||
                .style(ButtonStyle::Primary)
 | 
			
		||||
                .disabled(next_page == 0),
 | 
			
		||||
            CreateButton::new(page_prev.to_custom_id())
 | 
			
		||||
                .label("◀️")
 | 
			
		||||
                .style(ButtonStyle::Secondary)
 | 
			
		||||
                .disabled(next_page == 0),
 | 
			
		||||
            CreateButton::new(page_refresh.to_custom_id())
 | 
			
		||||
                .label("🔁")
 | 
			
		||||
                .style(ButtonStyle::Secondary),
 | 
			
		||||
            CreateButton::new(page_next.to_custom_id())
 | 
			
		||||
                .label("▶️")
 | 
			
		||||
                .style(ButtonStyle::Secondary)
 | 
			
		||||
                .disabled(next_page + 1 == max_pages),
 | 
			
		||||
            CreateButton::new(page_last.to_custom_id())
 | 
			
		||||
                .label("⏭️")
 | 
			
		||||
                .style(ButtonStyle::Primary)
 | 
			
		||||
                .disabled(next_page + 1 == max_pages),
 | 
			
		||||
        ])
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -150,41 +140,33 @@ impl Pager for DelPager {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize, comp: &mut CreateComponents) {
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize) -> CreateActionRow {
 | 
			
		||||
        let next_page = self.next_page(max_pages);
 | 
			
		||||
 | 
			
		||||
        let (page_first, page_prev, page_refresh, page_next, page_last) =
 | 
			
		||||
            DelPager::buttons(next_page, self.timezone);
 | 
			
		||||
 | 
			
		||||
        comp.create_action_row(|row| {
 | 
			
		||||
            row.create_button(|b| {
 | 
			
		||||
                b.label("⏮️")
 | 
			
		||||
                    .style(ButtonStyle::Primary)
 | 
			
		||||
                    .custom_id(page_first.to_custom_id())
 | 
			
		||||
                    .disabled(next_page == 0)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("◀️")
 | 
			
		||||
                    .style(ButtonStyle::Secondary)
 | 
			
		||||
                    .custom_id(page_prev.to_custom_id())
 | 
			
		||||
                    .disabled(next_page == 0)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("🔁").style(ButtonStyle::Secondary).custom_id(page_refresh.to_custom_id())
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("▶️")
 | 
			
		||||
                    .style(ButtonStyle::Secondary)
 | 
			
		||||
                    .custom_id(page_next.to_custom_id())
 | 
			
		||||
                    .disabled(next_page + 1 == max_pages)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("⏭️")
 | 
			
		||||
                    .style(ButtonStyle::Primary)
 | 
			
		||||
                    .custom_id(page_last.to_custom_id())
 | 
			
		||||
                    .disabled(next_page + 1 == max_pages)
 | 
			
		||||
            })
 | 
			
		||||
        });
 | 
			
		||||
        CreateActionRow::Buttons(vec![
 | 
			
		||||
            CreateButton::new(page_first.to_custom_id())
 | 
			
		||||
                .label("⏮️")
 | 
			
		||||
                .style(ButtonStyle::Primary)
 | 
			
		||||
                .disabled(next_page == 0),
 | 
			
		||||
            CreateButton::new(page_prev.to_custom_id())
 | 
			
		||||
                .label("◀️")
 | 
			
		||||
                .style(ButtonStyle::Secondary)
 | 
			
		||||
                .disabled(next_page == 0),
 | 
			
		||||
            CreateButton::new(page_refresh.to_custom_id())
 | 
			
		||||
                .label("🔁")
 | 
			
		||||
                .style(ButtonStyle::Secondary),
 | 
			
		||||
            CreateButton::new(page_next.to_custom_id())
 | 
			
		||||
                .label("▶️")
 | 
			
		||||
                .style(ButtonStyle::Secondary)
 | 
			
		||||
                .disabled(next_page + 1 == max_pages),
 | 
			
		||||
            CreateButton::new(page_last.to_custom_id())
 | 
			
		||||
                .label("⏭️")
 | 
			
		||||
                .style(ButtonStyle::Primary)
 | 
			
		||||
                .disabled(next_page + 1 == max_pages),
 | 
			
		||||
        ])
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -233,41 +215,33 @@ impl Pager for TodoPager {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize, comp: &mut CreateComponents) {
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize) -> CreateActionRow {
 | 
			
		||||
        let next_page = self.next_page(max_pages);
 | 
			
		||||
 | 
			
		||||
        let (page_first, page_prev, page_refresh, page_next, page_last) =
 | 
			
		||||
            TodoPager::buttons(next_page, self.user_id, self.channel_id, self.guild_id);
 | 
			
		||||
 | 
			
		||||
        comp.create_action_row(|row| {
 | 
			
		||||
            row.create_button(|b| {
 | 
			
		||||
                b.label("⏮️")
 | 
			
		||||
                    .style(ButtonStyle::Primary)
 | 
			
		||||
                    .custom_id(page_first.to_custom_id())
 | 
			
		||||
                    .disabled(next_page == 0)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("◀️")
 | 
			
		||||
                    .style(ButtonStyle::Secondary)
 | 
			
		||||
                    .custom_id(page_prev.to_custom_id())
 | 
			
		||||
                    .disabled(next_page == 0)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("🔁").style(ButtonStyle::Secondary).custom_id(page_refresh.to_custom_id())
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("▶️")
 | 
			
		||||
                    .style(ButtonStyle::Secondary)
 | 
			
		||||
                    .custom_id(page_next.to_custom_id())
 | 
			
		||||
                    .disabled(next_page + 1 == max_pages)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("⏭️")
 | 
			
		||||
                    .style(ButtonStyle::Primary)
 | 
			
		||||
                    .custom_id(page_last.to_custom_id())
 | 
			
		||||
                    .disabled(next_page + 1 == max_pages)
 | 
			
		||||
            })
 | 
			
		||||
        });
 | 
			
		||||
        CreateActionRow::Buttons(vec![
 | 
			
		||||
            CreateButton::new(page_first.to_custom_id())
 | 
			
		||||
                .label("⏮️")
 | 
			
		||||
                .style(ButtonStyle::Primary)
 | 
			
		||||
                .disabled(next_page == 0),
 | 
			
		||||
            CreateButton::new(page_prev.to_custom_id())
 | 
			
		||||
                .label("◀️")
 | 
			
		||||
                .style(ButtonStyle::Secondary)
 | 
			
		||||
                .disabled(next_page == 0),
 | 
			
		||||
            CreateButton::new(page_refresh.to_custom_id())
 | 
			
		||||
                .label("🔁")
 | 
			
		||||
                .style(ButtonStyle::Secondary),
 | 
			
		||||
            CreateButton::new(page_next.to_custom_id())
 | 
			
		||||
                .label("▶️")
 | 
			
		||||
                .style(ButtonStyle::Secondary)
 | 
			
		||||
                .disabled(next_page + 1 == max_pages),
 | 
			
		||||
            CreateButton::new(page_last.to_custom_id())
 | 
			
		||||
                .label("⏭️")
 | 
			
		||||
                .style(ButtonStyle::Primary)
 | 
			
		||||
                .disabled(next_page + 1 == max_pages),
 | 
			
		||||
        ])
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -350,41 +324,33 @@ impl Pager for MacroPager {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize, comp: &mut CreateComponents) {
 | 
			
		||||
    fn create_button_row(&self, max_pages: usize) -> CreateActionRow {
 | 
			
		||||
        let next_page = self.next_page(max_pages);
 | 
			
		||||
 | 
			
		||||
        let (page_first, page_prev, page_refresh, page_next, page_last) =
 | 
			
		||||
            MacroPager::buttons(next_page);
 | 
			
		||||
 | 
			
		||||
        comp.create_action_row(|row| {
 | 
			
		||||
            row.create_button(|b| {
 | 
			
		||||
                b.label("⏮️")
 | 
			
		||||
                    .style(ButtonStyle::Primary)
 | 
			
		||||
                    .custom_id(page_first.to_custom_id())
 | 
			
		||||
                    .disabled(next_page == 0)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("◀️")
 | 
			
		||||
                    .style(ButtonStyle::Secondary)
 | 
			
		||||
                    .custom_id(page_prev.to_custom_id())
 | 
			
		||||
                    .disabled(next_page == 0)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("🔁").style(ButtonStyle::Secondary).custom_id(page_refresh.to_custom_id())
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("▶️")
 | 
			
		||||
                    .style(ButtonStyle::Secondary)
 | 
			
		||||
                    .custom_id(page_next.to_custom_id())
 | 
			
		||||
                    .disabled(next_page + 1 == max_pages)
 | 
			
		||||
            })
 | 
			
		||||
            .create_button(|b| {
 | 
			
		||||
                b.label("⏭️")
 | 
			
		||||
                    .style(ButtonStyle::Primary)
 | 
			
		||||
                    .custom_id(page_last.to_custom_id())
 | 
			
		||||
                    .disabled(next_page + 1 == max_pages)
 | 
			
		||||
            })
 | 
			
		||||
        });
 | 
			
		||||
        CreateActionRow::Buttons(vec![
 | 
			
		||||
            CreateButton::new(page_first.to_custom_id())
 | 
			
		||||
                .label("⏮️")
 | 
			
		||||
                .style(ButtonStyle::Primary)
 | 
			
		||||
                .disabled(next_page == 0),
 | 
			
		||||
            CreateButton::new(page_prev.to_custom_id())
 | 
			
		||||
                .label("◀️")
 | 
			
		||||
                .style(ButtonStyle::Secondary)
 | 
			
		||||
                .disabled(next_page == 0),
 | 
			
		||||
            CreateButton::new(page_refresh.to_custom_id())
 | 
			
		||||
                .label("🔁")
 | 
			
		||||
                .style(ButtonStyle::Secondary),
 | 
			
		||||
            CreateButton::new(page_next.to_custom_id())
 | 
			
		||||
                .label("▶️")
 | 
			
		||||
                .style(ButtonStyle::Secondary)
 | 
			
		||||
                .disabled(next_page + 1 == max_pages),
 | 
			
		||||
            CreateButton::new(page_last.to_custom_id())
 | 
			
		||||
                .label("⏭️")
 | 
			
		||||
                .style(ButtonStyle::Primary)
 | 
			
		||||
                .disabled(next_page + 1 == max_pages),
 | 
			
		||||
        ])
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user