change ProjectPage callback's keyboard generation
This commit is contained in:
parent
38c38cec8e
commit
caca9e354d
39
src/main.rs
39
src/main.rs
@ -306,28 +306,39 @@ async fn callback_handler(bot: Bot, mut db: DB, q: CallbackQuery) -> BotResult<(
|
|||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
Callback::ProjectPage { id } => {
|
Callback::ProjectPage { id } => {
|
||||||
let nextproject = db
|
let nextproject = match db
|
||||||
.get_literal_value(&format!("project_{}_msg", id + 1))
|
.get_literal_value(&format!("project_{}_msg", id + 1))
|
||||||
.await?
|
.await?
|
||||||
.unwrap_or("emptyproject".into());
|
.unwrap_or("emptyproject".into())
|
||||||
let keyboard = match nextproject.to_lowercase().as_str() {
|
.as_str()
|
||||||
"end" | "empty" | "none" => {
|
{
|
||||||
stacked_buttons_markup!(
|
"end" | "empty" | "none" => None,
|
||||||
create_callback_button("go_home", Callback::GoHome, &mut db).await?
|
_ => Some(
|
||||||
)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
stacked_buttons_markup!(
|
|
||||||
create_callback_button(
|
create_callback_button(
|
||||||
"next_project",
|
"next_project",
|
||||||
Callback::ProjectPage { id: id + 1 },
|
Callback::ProjectPage { id: id + 1 },
|
||||||
&mut db
|
&mut db,
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
create_callback_button("go_home", Callback::GoHome, &mut db).await?
|
),
|
||||||
)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
let prevproject = match id.wrapping_sub(1) {
|
||||||
|
0 => None,
|
||||||
|
_ => Some(
|
||||||
|
create_callback_button(
|
||||||
|
"prev_project",
|
||||||
|
Callback::ProjectPage {
|
||||||
|
id: id.wrapping_sub(1),
|
||||||
|
},
|
||||||
|
&mut db,
|
||||||
|
)
|
||||||
|
.await?,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
let keyboard = buttons_markup!(
|
||||||
|
[prevproject, nextproject].into_iter().flatten(),
|
||||||
|
[create_callback_button("go_home", Callback::GoHome, &mut db).await?]
|
||||||
|
);
|
||||||
|
|
||||||
replace_message(
|
replace_message(
|
||||||
&bot,
|
&bot,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user