no list message when no record
This commit is contained in:
parent
74f04c3ce0
commit
1fd4fb91f4
@ -13,8 +13,8 @@ use crate::{
|
|||||||
db_controller::PaginatedRecordData,
|
db_controller::PaginatedRecordData,
|
||||||
messages::{
|
messages::{
|
||||||
BOT_ABOUT, BOT_BUTTON_END, BOT_BUTTON_HEAD, BOT_BUTTON_NEXT, BOT_BUTTON_PREV, BOT_HELP,
|
BOT_ABOUT, BOT_BUTTON_END, BOT_BUTTON_HEAD, BOT_BUTTON_NEXT, BOT_BUTTON_PREV, BOT_HELP,
|
||||||
BOT_TEXT_DELETED, BOT_TEXT_LOADING, BOT_TEXT_MUTE_STATUS, BOT_TEXT_STATUS_OFF,
|
BOT_TEXT_DELETED, BOT_TEXT_LOADING, BOT_TEXT_MUTE_STATUS, BOT_TEXT_NO_LIST,
|
||||||
BOT_TEXT_STATUS_ON, BOT_TEXT_WELCOME,
|
BOT_TEXT_STATUS_OFF, BOT_TEXT_STATUS_ON, BOT_TEXT_WELCOME,
|
||||||
},
|
},
|
||||||
telegram_bot::BotServer,
|
telegram_bot::BotServer,
|
||||||
};
|
};
|
||||||
@ -315,15 +315,20 @@ impl CommandHandler {
|
|||||||
page: usize,
|
page: usize,
|
||||||
) -> String {
|
) -> String {
|
||||||
let mut msg = String::from("```");
|
let mut msg = String::from("```");
|
||||||
|
|
||||||
for (message, _) in paginated_record_data.current_data.iter() {
|
for (message, _) in paginated_record_data.current_data.iter() {
|
||||||
msg = format!("{}\n{}\t\t\t\t{}", msg, message.id, message.message);
|
msg = format!("{}\n{}\t\t\t\t{}", msg, message.id, message.message);
|
||||||
}
|
}
|
||||||
|
if paginated_record_data.items_count == 0 {
|
||||||
|
msg = BOT_TEXT_NO_LIST.to_string();
|
||||||
|
} else {
|
||||||
msg = format!(
|
msg = format!(
|
||||||
"{}\n```\n{}/{}",
|
"{}\n```\n{}/{}",
|
||||||
msg,
|
msg,
|
||||||
page + 1,
|
page + 1,
|
||||||
paginated_record_data.pages_count
|
paginated_record_data.pages_count
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
msg
|
msg
|
||||||
}
|
}
|
||||||
|
@ -20,3 +20,4 @@ pub const BOT_BUTTON_END: &'static str = "末页 ⏭";
|
|||||||
pub const BOT_BUTTON_PREV: &'static str = "⏪ 上一页";
|
pub const BOT_BUTTON_PREV: &'static str = "⏪ 上一页";
|
||||||
pub const BOT_BUTTON_NEXT: &'static str = "下一页 ⏩";
|
pub const BOT_BUTTON_NEXT: &'static str = "下一页 ⏩";
|
||||||
pub const BOT_TEXT_LOADING: &'static str = "⌛️ 载入中……";
|
pub const BOT_TEXT_LOADING: &'static str = "⌛️ 载入中……";
|
||||||
|
pub const BOT_TEXT_NO_LIST: &'static str = "没有记录";
|
||||||
|
Loading…
Reference in New Issue
Block a user