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.
embed
Manos Pitsidianakis 2019-09-20 09:10:33 +03:00
parent 7dc3efaedd
commit fe28e849b3
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
2 changed files with 14 additions and 5 deletions

View File

@ -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(

View File

@ -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();