Merge pull request #1740 from deltachat/use-error-network

avoid popping up "IMAP Connect without configured params"
This commit is contained in:
bjoern
2020-07-21 16:42:23 +02:00
committed by GitHub
4 changed files with 13 additions and 5 deletions

View File

@@ -4132,14 +4132,12 @@ void dc_event_unref(dc_event_t* event);
* Network errors should be reported to users in a non-disturbing way,
* however, as network errors may come in a sequence,
* it is not useful to raise each an every error to the user.
* For this purpose, data1 is set to 1 if the error is probably worth reporting.
*
* Moreover, if the UI detects that the device is offline,
* it is probably more useful to report this to the user
* instead of the string from data2.
*
* @param data1 (int) 1=first/new network error, should be reported the user;
* 0=subsequent network error, should be logged only
* @param data1 0
* @param data2 (char*) Error string, always set, never NULL.
*/
#define DC_EVENT_ERROR_NETWORK 401

View File

@@ -140,7 +140,6 @@ pub enum Event {
/// Network errors should be reported to users in a non-disturbing way,
/// however, as network errors may come in a sequence,
/// it is not useful to raise each an every error to the user.
/// For this purpose, data1 is set to 1 if the error is probably worth reporting.
///
/// Moreover, if the UI detects that the device is offline,
/// it is probably more useful to report this to the user

View File

@@ -41,6 +41,17 @@ macro_rules! error {
}};
}
#[macro_export]
macro_rules! error_network {
($ctx:expr, $msg:expr) => {
error_network!($ctx, $msg,)
};
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
emit_event!($ctx, $crate::Event::ErrorNetwork(formatted));
}};
}
#[macro_export]
macro_rules! emit_event {
($ctx:expr, $event:expr) => {

View File

@@ -105,7 +105,7 @@ async fn fetch(ctx: &Context, connection: &mut Imap) {
match ctx.get_config(Config::ConfiguredInboxFolder).await {
Some(watch_folder) => {
if let Err(err) = connection.connect_configured(&ctx).await {
error!(ctx, "{}", err);
error_network!(ctx, "{}", err);
return;
}