diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-12-15 08:52:22 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-12-15 08:55:08 +0200 |
commit | 020124178683d00d328cb50079cc921a9622317b (patch) | |
tree | 32464aaad479f5b929007cb783ca7ad0555b241d /ui/src/components/mail/listing.rs | |
parent | 17a0f31b3e2b88e15aba1662fd1ee5bd828b91fd (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.rs | 12 |
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(_) => { |