Code cleanup

This commit is contained in:
2024-02-22 12:44:02 +03:00
parent 8979cc5b25
commit b526eb0c12
18 changed files with 124 additions and 148 deletions

View File

@@ -1,20 +1,18 @@
use crate::prelude::*;
use tokio::task::spawn_blocking;
#[inline]
pub async fn menu(bot: Throttle<Bot>, msg: Message, db: Pool) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
let names: Vec<String> = Account::get_names(user_id, &db).try_collect().await?;
let markup = menu_markup("get", user_id, &db).await?;
if names.is_empty() {
if markup.inline_keyboard.is_empty() {
bot.send_message(msg.chat.id, "You don't have any accounts")
.reply_markup(deletion_markup())
.await?;
return Ok(());
}
let markup = spawn_blocking(|| menu_markup_sync("get", names)).await?;
bot.send_message(msg.chat.id, "Choose your account")
.reply_markup(markup)
.await?;