summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-09-20 09:10:33 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-09-20 09:10:33 +0300
commitfe28e849b3f257f39bd812bb7c55ccb6c05f6349 (patch)
tree7650e993a5d88de1ee837072db4d7dee39d046d2
parent7dc3efaedd57654c8762f7900b57dae7a7858f43 (diff)
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.
-rw-r--r--ui/src/conf/accounts.rs14
-rw-r--r--ui/src/state.rs5
2 files changed, 14 insertions, 5 deletions
diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs
index eb33a9bc..1308a800 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<FolderHash, MailboxEntry>,
pub(crate) folder_confs: FnvHashMap<FolderHash, FolderConf>,
@@ -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<FolderHash, Folder> = 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 a1007259..f7782838 100644
--- a/ui/src/state.rs
+++ b/ui/src/state.rs
@@ -184,9 +184,11 @@ impl State {
let mut accounts: Vec<Account> = 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();