From fe28e849b3f257f39bd812bb7c55ccb6c05f6349 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 20 Sep 2019 09:10:33 +0300 Subject: [PATCH] ui: send update event on folders even on no notification Send an update event even if user's configuration has turned off notification for this special event. This happens if the entire folder is set to `ignore`, or when a particular thread is snoozed. In every case we would want the UI to update. --- ui/src/conf/accounts.rs | 14 +++++++++++--- ui/src/state.rs | 5 +++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs index eb33a9bca..1308a8005 100644 --- a/ui/src/conf/accounts.rs +++ b/ui/src/conf/accounts.rs @@ -116,6 +116,7 @@ impl MailboxEntry { #[derive(Debug)] pub struct Account { + pub index: usize, name: String, pub(crate) folders: FnvHashMap, pub(crate) folder_confs: FnvHashMap, @@ -193,7 +194,13 @@ struct FolderNode { } impl Account { - pub fn new(name: String, settings: AccountConf, map: &Backends, notify_fn: NotifyFn) -> Self { + pub fn new( + index: usize, + name: String, + settings: AccountConf, + map: &Backends, + notify_fn: NotifyFn, + ) -> Self { let s = settings.clone(); let mut backend = map.get(settings.account().format())( settings.account(), @@ -303,6 +310,7 @@ impl Account { }; Account { + index, name, folders, folder_confs, @@ -444,11 +452,11 @@ impl Account { let ref_folders: FnvHashMap = self.backend.folders(); let folder_conf = &self.settings.folder_confs[&self.folder_names[&folder_hash]]; if folder_conf.ignore.is_true() { - return None; + return Some(UIEvent::MailboxUpdate((self.index, folder_hash))); } let (_, thread_node) = self.mail_and_thread(env_hash, folder_hash); if thread_node.snoozed() { - return None; + return Some(UIEvent::MailboxUpdate((self.index, folder_hash))); } let env = self.get_env(&env_hash); return Some(Notification( diff --git a/ui/src/state.rs b/ui/src/state.rs index a1007259c..f77828389 100644 --- a/ui/src/state.rs +++ b/ui/src/state.rs @@ -184,9 +184,11 @@ impl State { let mut accounts: Vec = settings .accounts .iter() - .map(|(n, a_s)| { + .enumerate() + .map(|(index, (n, a_s))| { let sender = sender.clone(); Account::new( + index, n.to_string(), a_s.clone(), &backends, @@ -199,7 +201,6 @@ impl State { }) .collect(); accounts.sort_by(|a, b| a.name().cmp(&b.name())); - log(format!("Initialized {} accounts.", accounts.len()), INFO); let _stdout = std::io::stdout(); _stdout.lock();