listing/*: show MailboxEntry::status() when length is 0

Show the MailboxEntry::status() string when self.length == 0, instead of
"MAILBOX is empty".
This commit is contained in:
Manos Pitsidianakis 2020-08-07 00:39:17 +03:00
parent 6d61d0651c
commit fe4dae12df
No known key found for this signature in database
GPG Key ID: 73627C2F690DF710
5 changed files with 12 additions and 7 deletions

View File

@ -438,7 +438,7 @@ impl MailListingTrait for CompactListing {
std::cmp::min(80, self.rows.len().saturating_sub(1)),
);
if self.length == 0 && self.filter_term.is_empty() {
let message = format!("{} is empty", account[&self.cursor_pos.1].name());
let message: String = account[&self.cursor_pos.1].status();
self.data_columns.columns[0] =
CellBuffer::new_with_context(message.len(), self.length + 1, default_cell, context);
write_string_to_grid(

View File

@ -471,7 +471,7 @@ impl MailListingTrait for ConversationsListing {
.set_attrs(self.color_cache.theme_default.attrs);
ret
};
let message = format!("{} is empty", account[&self.cursor_pos.1].name());
let message: String = account[&self.cursor_pos.1].status();
self.content = CellBuffer::new_with_context(message.len(), 1, default_cell, context);
write_string_to_grid(
&message,

View File

@ -980,7 +980,7 @@ impl PlainListing {
}
}
if self.length == 0 && self.filter_term.is_empty() {
let message = format!("{} is empty", account[&self.cursor_pos.1].name());
let message: String = account[&self.cursor_pos.1].status();
self.data_columns.columns[0] =
CellBuffer::new_with_context(message.len(), self.length + 1, default_cell, context);
write_string_to_grid(

View File

@ -239,7 +239,7 @@ impl MailListingTrait for ThreadListing {
ret
};
if threads.len() == 0 {
let message = format!("Mailbox `{}` is empty.", account[&self.cursor_pos.1].name());
let message: String = account[&self.cursor_pos.1].status();
self.data_columns.columns[0] =
CellBuffer::new_with_context(message.len(), 1, default_cell, context);
write_string_to_grid(

View File

@ -117,9 +117,13 @@ pub struct MailboxEntry {
impl MailboxEntry {
pub fn status(&self) -> String {
match self.status {
MailboxStatus::Available => self.name().to_string(),
MailboxStatus::Available => format!(
"{} [{} messages]",
self.name(),
self.ref_mailbox.count().ok().unwrap_or((0, 0)).1
),
MailboxStatus::Failed(ref e) => e.to_string(),
MailboxStatus::None => "Retrieving mailbox".to_string(),
MailboxStatus::None => "Retrieving mailbox.".to_string(),
MailboxStatus::Parsing(done, total) => {
format!("Parsing messages. [{}/{}]", done, total)
}
@ -572,7 +576,8 @@ impl Account {
if entry.conf.mailbox_conf.autoload
|| entry.ref_mailbox.special_usage() == SpecialUsageMailbox::Inbox
{
entry.status = MailboxStatus::Parsing(0, 0);
let total = entry.ref_mailbox.count().ok().unwrap_or((0, 0)).1;
entry.status = MailboxStatus::Parsing(0, total);
if self.backend_capabilities.is_async {
if let Ok(mailbox_job) = self.backend.write().unwrap().fetch_async(*h) {
let mailbox_job = mailbox_job.into_future();