From f033463db90fcdd441d5641d9dfb40e2b64b2410 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Wed, 15 Aug 2018 15:32:30 +0300 Subject: [PATCH] startupcheck signal seems to be causing redraws closes #33 --- melib/src/mailbox/accounts.rs | 6 +++--- src/bin.rs | 10 ++++++++-- ui/src/components/mail/listing/compact.rs | 2 +- ui/src/components/mail/listing/mod.rs | 2 +- ui/src/components/mail/mod.rs | 2 +- ui/src/components/utilities.rs | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/melib/src/mailbox/accounts.rs b/melib/src/mailbox/accounts.rs index 25068c16..e943aa29 100644 --- a/melib/src/mailbox/accounts.rs +++ b/melib/src/mailbox/accounts.rs @@ -122,10 +122,10 @@ impl Account { }; } - pub fn status(&mut self, index: usize) -> result::Result<(), usize> { + pub fn status(&mut self, index: usize) -> result::Result { match self.workers[index].as_mut() { None => { - return Ok(()); + return Ok(false); } Some(ref mut w) => match w.poll() { Ok(AsyncStatus::NoUpdate) => { @@ -144,7 +144,7 @@ impl Account { let m = self.workers[index].take().unwrap().extract(); self.load_mailbox(index, m); self.workers[index] = None; - Ok(()) + Ok(true) } } diff --git a/src/bin.rs b/src/bin.rs index 817abd48..52676c2d 100644 --- a/src/bin.rs +++ b/src/bin.rs @@ -191,11 +191,15 @@ fn main() { } ThreadEvent::UIEvent(UIEventType::StartupCheck) => { let mut flag = false; + let mut render_flag = false; for account in &mut state.context.accounts { let len = account.len(); for i in 0..len { match account.status(i) { - Ok(()) => { }, + Ok(true) => { + render_flag = true; + }, + Ok(false) => {}, Err(_) => { flag |= true; } @@ -205,7 +209,9 @@ fn main() { if !flag { state.finish_startup(); } - state.render(); + if render_flag { + state.render(); + } } ThreadEvent::UIEvent(e) => { state.rcv_event(UIEvent { id: 0, event_type: e}); diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index 9c500706..13ec64fa 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -86,7 +86,7 @@ impl CompactMailListing { // loop { // TODO: Show progress visually - if let Ok(()) = context.accounts[self.cursor_pos.0].status(self.cursor_pos.1) { + if let Ok(_) = context.accounts[self.cursor_pos.0].status(self.cursor_pos.1) { break; } } diff --git a/ui/src/components/mail/listing/mod.rs b/ui/src/components/mail/listing/mod.rs index c7eee344..d82fe1a8 100644 --- a/ui/src/components/mail/listing/mod.rs +++ b/ui/src/components/mail/listing/mod.rs @@ -106,7 +106,7 @@ impl MailListing { // loop { // TODO: Show progress visually - if let Ok(()) = context.accounts[self.cursor_pos.0].status(self.cursor_pos.1) { + if let Ok(_) = context.accounts[self.cursor_pos.0].status(self.cursor_pos.1) { break; } } diff --git a/ui/src/components/mail/mod.rs b/ui/src/components/mail/mod.rs index b9714332..5c4e8e85 100644 --- a/ui/src/components/mail/mod.rs +++ b/ui/src/components/mail/mod.rs @@ -136,7 +136,7 @@ impl AccountMenu { ) -> () { let len = s.len(); match context.accounts[index].status(root) { - Ok(()) => {} + Ok(_) => {} Err(_) => { return; // TODO: Show progress visually diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index 6d003304..52fc0ee5 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -474,7 +474,7 @@ impl Component for StatusBar { match &event.event_type { UIEventType::RefreshMailbox((ref idx_a, ref idx_f)) => { match context.accounts[*idx_a].status(*idx_f) { - Ok(()) => {} + Ok(_) => {} Err(_) => { return; }