summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-15 12:41:31 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-20 16:03:06 +0200
commit20f86f2741cb1d78c983b723cfc5f927846e7354 (patch)
tree38459f623c681807879778c68af026fa242d04dc /ui
parent0ac10aa4d08143b3b5728d1e0f4c5528219edd56 (diff)
ui/listing: add mailbox reload rate limit
Diffstat (limited to 'ui')
-rw-r--r--ui/src/components/mail/listing.rs30
-rw-r--r--ui/src/conf/accounts.rs6
2 files changed, 36 insertions, 0 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs
index 420211a7..67c38233 100644
--- a/ui/src/components/mail/listing.rs
+++ b/ui/src/components/mail/listing.rs
@@ -238,6 +238,7 @@ pub struct Listing {
dirty: bool,
visible: bool,
cursor_pos: (usize, usize),
+ startup_checks_rate: RateLimit,
id: ComponentId,
show_divider: bool,
@@ -358,6 +359,34 @@ impl Component for Listing {
self.dirty = false;
}
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
+ match event {
+ UIEvent::StartupCheck(ref f) => {
+ if context.accounts[self.component.coordinates().0]
+ .folders_order
+ .get(self.component.coordinates().1)
+ .map(|&folder_hash| *f == folder_hash)
+ .unwrap_or(false)
+ {
+ if !self.startup_checks_rate.tick() {
+ return false;
+ }
+ }
+ }
+ UIEvent::Timer(n) if *n == self.startup_checks_rate.id() => {
+ if self.startup_checks_rate.active {
+ self.startup_checks_rate.reset();
+ if let Some(folder_hash) = context.accounts[self.component.coordinates().0]
+ .folders_order
+ .get(self.component.coordinates().1)
+ {
+ return self
+ .process_event(&mut UIEvent::StartupCheck(*folder_hash), context);
+ }
+ }
+ }
+ _ => {}
+ }
+
if self.component.process_event(event, context) {
return true;
}
@@ -811,6 +840,7 @@ impl Listing {
visible: true,
dirty: true,
cursor_pos: (0, 0),
+ startup_checks_rate: RateLimit::new(2, 1000),
id: ComponentId::new_v4(),
show_divider: false,
menu_visibility: true,
diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs
index 67df5e2a..de63ddba 100644
--- a/ui/src/conf/accounts.rs
+++ b/ui/src/conf/accounts.rs
@@ -847,6 +847,12 @@ impl Account {
};
*f = MailboxEntry::Available(m);
});
+ self.sender
+ .send(ThreadEvent::UIEvent(UIEvent::MailboxUpdate((
+ self.index,
+ folder_hash,
+ ))))
+ .unwrap();
self.workers.insert(folder_hash, None);
}