ui: change Component::get_status return type
There was no reason to return Option<String>, just return String::new() instead of Option::Noneasync
parent
cadb1e1613
commit
9b7875c023
|
@ -75,7 +75,7 @@ pub trait Component: Display + Debug + Send {
|
|||
Default::default()
|
||||
}
|
||||
|
||||
fn get_status(&self, _context: &Context) -> Option<String> {
|
||||
None
|
||||
fn get_status(&self, _context: &Context) -> String {
|
||||
String::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -670,7 +670,7 @@ impl Component for ContactList {
|
|||
context
|
||||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateStatus(
|
||||
self.get_status(context).unwrap(),
|
||||
self.get_status(context),
|
||||
)));
|
||||
}
|
||||
|
||||
|
@ -707,7 +707,7 @@ impl Component for ContactList {
|
|||
context
|
||||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateStatus(
|
||||
self.get_status(context).unwrap(),
|
||||
self.get_status(context),
|
||||
)));
|
||||
}
|
||||
return true;
|
||||
|
@ -894,10 +894,10 @@ impl Component for ContactList {
|
|||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
fn get_status(&self, context: &Context) -> Option<String> {
|
||||
Some(format!(
|
||||
fn get_status(&self, context: &Context) -> String {
|
||||
format!(
|
||||
"{} entries",
|
||||
context.accounts[self.account_pos].address_book.len()
|
||||
))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -545,7 +545,7 @@ impl Component for Listing {
|
|||
context
|
||||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateStatus(
|
||||
self.get_status(context).unwrap(),
|
||||
self.get_status(context),
|
||||
)));
|
||||
return true;
|
||||
}
|
||||
|
@ -613,7 +613,7 @@ impl Component for Listing {
|
|||
context
|
||||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateStatus(
|
||||
self.get_status(context).unwrap(),
|
||||
self.get_status(context),
|
||||
)));
|
||||
return true;
|
||||
}
|
||||
|
@ -798,7 +798,7 @@ impl Component for Listing {
|
|||
context
|
||||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateStatus(
|
||||
self.get_status(context).unwrap(),
|
||||
self.get_status(context),
|
||||
)));
|
||||
}
|
||||
UIEvent::MailboxUpdate(_) => {
|
||||
|
@ -806,7 +806,7 @@ impl Component for Listing {
|
|||
context
|
||||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateStatus(
|
||||
self.get_status(context).unwrap(),
|
||||
self.get_status(context),
|
||||
)));
|
||||
}
|
||||
UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt('')) => {
|
||||
|
@ -852,32 +852,27 @@ impl Component for Listing {
|
|||
self.component.set_id(id);
|
||||
}
|
||||
|
||||
fn get_status(&self, context: &Context) -> Option<String> {
|
||||
Some({
|
||||
let folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0]
|
||||
.folders_order
|
||||
fn get_status(&self, context: &Context) -> String {
|
||||
let folder_hash = if let Some((_, folder_hash)) = self.accounts[self.cursor_pos.0]
|
||||
.entries
|
||||
.get(self.cursor_pos.1)
|
||||
{
|
||||
*h
|
||||
*folder_hash
|
||||
} else {
|
||||
return Some(String::new());
|
||||
return String::new();
|
||||
};
|
||||
if !context.accounts[self.cursor_pos.0].folders[&folder_hash].is_available() {
|
||||
return Some(String::new());
|
||||
}
|
||||
|
||||
let account = &context.accounts[self.cursor_pos.0];
|
||||
let m = if account[self.cursor_pos.1].is_available() {
|
||||
account[self.cursor_pos.1].unwrap()
|
||||
} else {
|
||||
return Some(String::new());
|
||||
};
|
||||
if let Ok(m) = account[folder_hash].as_result() {
|
||||
format!(
|
||||
"Mailbox: {}, Messages: {}, New: {}",
|
||||
m.folder.name(),
|
||||
m.envelopes.len(),
|
||||
m.folder.count().ok().map(|(v, _)| v).unwrap_or(0),
|
||||
)
|
||||
})
|
||||
} else {
|
||||
account[folder_hash].to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1619,9 +1619,7 @@ impl Component for Tabbed {
|
|||
context
|
||||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateStatus(
|
||||
self.children[self.cursor_pos]
|
||||
.get_status(context)
|
||||
.unwrap_or_default(),
|
||||
self.children[self.cursor_pos].get_status(context),
|
||||
)));
|
||||
self.set_dirty(true);
|
||||
}
|
||||
|
@ -1632,9 +1630,7 @@ impl Component for Tabbed {
|
|||
context
|
||||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateStatus(
|
||||
self.children[self.cursor_pos]
|
||||
.get_status(context)
|
||||
.unwrap_or_default(),
|
||||
self.children[self.cursor_pos].get_status(context),
|
||||
)));
|
||||
self.set_dirty(true);
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue