summaryrefslogtreecommitdiffstats
path: root/ui/src/components/mail/listing.rs
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-12-15 08:52:22 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-12-15 08:55:08 +0200
commit020124178683d00d328cb50079cc921a9622317b (patch)
tree32464aaad479f5b929007cb783ca7ad0555b241d /ui/src/components/mail/listing.rs
parent17a0f31b3e2b88e15aba1662fd1ee5bd828b91fd (diff)
melib/backends: MailBackend::refresh() returns Result
Handle cases were refresh() would fail properly. Fixes a crash reported in #13
Diffstat (limited to 'ui/src/components/mail/listing.rs')
-rw-r--r--ui/src/components/mail/listing.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs
index 24ed7c94..c78a0731 100644
--- a/ui/src/components/mail/listing.rs
+++ b/ui/src/components/mail/listing.rs
@@ -676,10 +676,16 @@ impl Component for Listing {
UIEvent::Input(ref key)
if shortcut!(key == shortcuts[Listing::DESCRIPTION]["refresh"]) =>
{
- let folder_hash =
- context.accounts[self.cursor_pos.0].folders_order[self.cursor_pos.1];
let account = &mut context.accounts[self.cursor_pos.0];
- account.refresh(folder_hash);
+ if let Some(&folder_hash) = account.folders_order.get(self.cursor_pos.1) {
+ if let Err(err) = account.refresh(folder_hash) {
+ context.replies.push_back(UIEvent::Notification(
+ Some("Could not refresh.".to_string()),
+ err.to_string(),
+ Some(NotificationType::INFO),
+ ));
+ }
+ }
return true;
}
UIEvent::StartupCheck(_) => {