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