From f05a4205f748126a6857c5e51bf31d0d3d752848 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Wed, 11 Dec 2019 00:17:11 +0200 Subject: [PATCH] melib/ui: small fixes - melib/imap: accept quoted strings with escaped quotes in protocol_parser - ui/accounts: return unavailabity correctly if folder's worker slot is empty instead of judging only by its vacancy - ui/MailView: set view as not dirty if envelope loading from backend fails so that it stops requesting it in every subsequent redraw --- melib/src/backends/imap/protocol_parser.rs | 3 +-- ui/src/components/mail/view.rs | 5 +++++ ui/src/conf/accounts.rs | 9 ++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/melib/src/backends/imap/protocol_parser.rs b/melib/src/backends/imap/protocol_parser.rs index 067ee279..2f93f7fb 100644 --- a/melib/src/backends/imap/protocol_parser.rs +++ b/melib/src/backends/imap/protocol_parser.rs @@ -815,8 +815,7 @@ pub fn quoted(input: &[u8]) -> IResult<&[u8], Vec> { let mut i = 1; while i < input.len() { - if input[i] == b'\"' { - //&& input[i - 1] != b'\\' { + if input[i] == b'\"' && (i == 0 || (input[i - 1] != b'\\')) { return match crate::email::parser::phrase(&input[1..i]) { IResult::Done(_, out) => IResult::Done(&input[i + 1..], out), e => e, diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index 27c2e52f..fe5369ba 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -513,6 +513,11 @@ impl Component for MailView { match envelope.body(op) { Ok(body) => body, Err(e) => { + self.dirty = false; + clear_area(grid, (set_y(upper_left, y), bottom_right)); + context + .dirty_areas + .push_back((set_y(upper_left, y), bottom_right)); context.replies.push_back(UIEvent::Notification( Some("Failed to open e-mail".to_string()), e.to_string(), diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs index 867c6fc6..b053fe83 100644 --- a/ui/src/conf/accounts.rs +++ b/ui/src/conf/accounts.rs @@ -827,7 +827,14 @@ impl Account { pub fn status(&mut self, folder_hash: FolderHash) -> result::Result<(), usize> { match self.workers.get_mut(&folder_hash).unwrap() { None => { - return Ok(()); + return if self.folders[&folder_hash].is_available() + || (self.folders[&folder_hash].is_parsing() + && self.collection.threads.contains_key(&folder_hash)) + { + Ok(()) + } else { + Err(0) + }; } Some(ref mut w) => match w.poll() { Ok(AsyncStatus::NoUpdate) => {