fix: don't emit configure progress events during background relay additions

reported by bjoern while testing the branch on iOS: the background addition
would start fast enough to still show up in the configure-progress bar
of the initial onboarding screen. This commit should fix that.
This commit is contained in:
holger krekel
2026-09-21 13:21:51 +02:00
parent 0eddb98354
commit 3d3a6352e9
3 changed files with 22 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ use rusqlite::Transaction;
use tokio::task::JoinSet; use tokio::task::JoinSet;
use crate::config::{self, Config}; use crate::config::{self, Config};
use crate::configure::{EnteredLoginParam, configure}; use crate::configure::{EnteredLoginParam, SILENT_PROGRESS, configure};
use crate::log::{LogExt, warn}; use crate::log::{LogExt, warn};
use crate::login_param::{EnteredCertificateChecks, EnteredImapLoginParam}; use crate::login_param::{EnteredCertificateChecks, EnteredImapLoginParam};
use crate::net::{connect_tcp, proxy::ProxyConfig}; use crate::net::{connect_tcp, proxy::ProxyConfig};
@@ -190,7 +190,9 @@ async fn maybe_add_additional_relays_inner(context: &Context, skip_network: bool
.await?; .await?;
let mark_as_autorelay = true; let mark_as_autorelay = true;
let param = login_param_from_host(host, mark_as_autorelay); let param = login_param_from_host(host, mark_as_autorelay);
let res = configure(context, &param, skip_network).await; let res = SILENT_PROGRESS
.scope((), configure(context, &param, skip_network))
.await;
if let Err(e) = res { if let Err(e) = res {
warn!( warn!(
context, context,

View File

@@ -1,6 +1,7 @@
use std::time::Duration; use std::time::Duration;
use super::*; use super::*;
use crate::EventType;
use crate::test_utils::{TestContext, TestContextManager}; use crate::test_utils::{TestContext, TestContextManager};
use crate::tools::SystemTime; use crate::tools::SystemTime;
@@ -44,6 +45,7 @@ async fn test_add_transport_from_candidates() -> Result<()> {
assert!(transports[0].addr.ends_with("@example.org")); assert!(transports[0].addr.ends_with("@example.org"));
let untried = untried_relay_candidates(t).await?; let untried = untried_relay_candidates(t).await?;
assert_eq!(untried, ["example.org"]); assert_eq!(untried, ["example.org"]);
assert!(configure_progress_emitted(t).await);
Ok(()) Ok(())
} }
@@ -99,6 +101,14 @@ async fn mark_defaults_tried(t: &TestContext, now: i64) -> Result<()> {
save_relay_candidates(t, DEFAULT_RELAY_CANDIDATES, now).await save_relay_candidates(t, DEFAULT_RELAY_CANDIDATES, now).await
} }
/// Consumes emitted events, telling whether a configure progress is among them.
async fn configure_progress_emitted(t: &TestContext) -> bool {
t.evtracker
.get_matching_opt(t, |evt| matches!(evt, EventType::ConfigureProgress { .. }))
.await
.is_some()
}
/// Tests that saving a candidate overwrites its stored timestamp. /// Tests that saving a candidate overwrites its stored timestamp.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_save_relay_candidate() -> Result<()> { async fn test_save_relay_candidate() -> Result<()> {
@@ -265,6 +275,7 @@ async fn test_maybe_add_additional_relays_add_one() -> Result<()> {
let transports_after = t.count_transports().await?; let transports_after = t.count_transports().await?;
assert_eq!(transports_after, transports_before + 1); assert_eq!(transports_after, transports_before + 1);
assert!(!configure_progress_emitted(t).await);
Ok(()) Ok(())
} }

View File

@@ -47,12 +47,19 @@ use crate::{EventType, autorelay, stock_str};
/// See <https://github.com/chatmail/core/issues/7608>. /// See <https://github.com/chatmail/core/issues/7608>.
pub(crate) const MAX_RELAYS: usize = 5; pub(crate) const MAX_RELAYS: usize = 5;
tokio::task_local! {
pub(crate) static SILENT_PROGRESS: ();
}
#[track_caller] #[track_caller]
fn emit_progress(ctx: &Context, progress: u16) { fn emit_progress(ctx: &Context, progress: u16) {
assert!( assert!(
progress <= 1000, progress <= 1000,
"value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success" "value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success"
); );
if SILENT_PROGRESS.try_with(|_| ()).is_ok() {
return;
}
ctx.emit_event(EventType::ConfigureProgress { ctx.emit_event(EventType::ConfigureProgress {
progress, progress,
comment: None, comment: None,