diff --git a/CHANGELOG.md b/CHANGELOG.md index 8007b53b7..7cc43f8a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - added a JSON RPC API, accessible through a WebSocket server, the CFFI bindings and the Node.js bindings #3463 ### Changes +- jsonrpc: auto restart io on setConfig for the following keys `sentbox_watch`, `mvbox_move` and `only_fetch_mvbox` #3542 - refactorings #3545 #3551 - use [pathlib](https://docs.python.org/3/library/pathlib.html) in provider update script #3543 - `dc_get_chat_media()` can return media globally #3528 diff --git a/deltachat-jsonrpc/src/api/mod.rs b/deltachat-jsonrpc/src/api/mod.rs index 95474c0ec..fabe091f0 100644 --- a/deltachat-jsonrpc/src/api/mod.rs +++ b/deltachat-jsonrpc/src/api/mod.rs @@ -671,11 +671,19 @@ async fn set_config( value: Option<&str>, ) -> Result<(), anyhow::Error> { if key.starts_with("ui.") { - ctx.set_ui_config(key, value).await + ctx.set_ui_config(key, value).await?; } else { ctx.set_config(Config::from_str(key).context("unknown key")?, value) - .await + .await?; + + match key { + "sentbox_watch" | "mvbox_move" | "only_fetch_mvbox" => { + ctx.restart_io_if_running().await; + } + _ => {} + } } + Ok(()) } async fn get_config( diff --git a/src/context.rs b/src/context.rs index c7f83d301..0d2168a79 100644 --- a/src/context.rs +++ b/src/context.rs @@ -239,6 +239,17 @@ impl Context { } } + /// Restarts the IO scheduler if it was running before + /// when it is not running this is an no-op + pub async fn restart_io_if_running(&self) { + info!(self, "restarting IO"); + let is_running = { self.inner.scheduler.read().await.is_some() }; + if is_running { + self.stop_io().await; + self.start_io().await; + } + } + /// Returns a reference to the underlying SQL instance. /// /// Warning: this is only here for testing, not part of the public API.