Add logging level to Generic jobs

Not every job success should be shown to the user, for example updating
the sqlite3 database. So introduce a level to only show relevant
notifications.
memfd
Manos Pitsidianakis 2020-08-26 19:15:31 +03:00
parent c6f11fb592
commit 843616221e
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
4 changed files with 21 additions and 9 deletions

View File

@ -287,6 +287,7 @@ pub trait MailListingTrait: ListingTrait {
handle,
channel,
on_finish: None,
logging_level: melib::LoggingLevel::DEBUG,
},
);
}
@ -325,6 +326,7 @@ pub trait MailListingTrait: ListingTrait {
handle,
channel,
on_finish: None,
logging_level: melib::LoggingLevel::DEBUG,
},
);
}

View File

@ -1194,6 +1194,7 @@ impl Component for MailView {
}
}
}))),
logging_level: melib::LoggingLevel::DEBUG,
},
);
return true;

View File

@ -174,6 +174,7 @@ pub enum JobRequest {
),
Generic {
name: Cow<'static, str>,
logging_level: melib::LoggingLevel,
handle: JoinHandle,
channel: JobChannel<()>,
on_finish: Option<crate::types::CallbackFn>,
@ -645,6 +646,7 @@ impl Account {
.into(),
handle,
channel,
logging_level: melib::LoggingLevel::TRACE,
on_finish: None,
},
);
@ -693,6 +695,7 @@ impl Account {
.into(),
handle,
channel,
logging_level: melib::LoggingLevel::TRACE,
on_finish: None,
},
);
@ -752,6 +755,7 @@ impl Account {
.into(),
handle,
channel,
logging_level: melib::LoggingLevel::TRACE,
on_finish: None,
},
);
@ -796,6 +800,7 @@ impl Account {
.into(),
handle,
channel,
logging_level: melib::LoggingLevel::TRACE,
on_finish: None,
},
);
@ -1950,6 +1955,7 @@ impl Account {
ref mut channel,
handle: _,
ref mut on_finish,
logging_level,
} => {
let r = channel.try_recv().unwrap();
match r {
@ -1962,16 +1968,18 @@ impl Account {
)))
.expect("Could not send event on main channel");
}
Some(Ok(_)) => {
self.sender
.send(ThreadEvent::UIEvent(UIEvent::Notification(
Some(format!("{}: {} succeeded", &self.name, name,)),
String::new(),
Some(crate::types::NotificationType::INFO),
)))
.expect("Could not send event on main channel");
Some(Ok(())) if on_finish.is_none() => {
if logging_level <= melib::LoggingLevel::INFO {
self.sender
.send(ThreadEvent::UIEvent(UIEvent::Notification(
Some(format!("{}: {} succeeded", &self.name, name,)),
String::new(),
Some(crate::types::NotificationType::INFO),
)))
.expect("Could not send event on main channel");
}
}
None => {}
Some(Ok(())) | None => {}
}
if on_finish.is_some() {
self.sender

View File

@ -882,6 +882,7 @@ impl State {
handle,
channel,
on_finish: None,
logging_level: melib::LoggingLevel::INFO,
},
);
self.context.replies.push_back(UIEvent::Notification(