From 7e543484bd36f062d083fc974edb740f16c9aede Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Mon, 8 Dec 2025 14:23:36 +0100 Subject: [PATCH 1/2] feat: jsonrpc api `get_all_ui_config_keys` to get all "ui.*" config keys --- deltachat-jsonrpc/src/api.rs | 8 +++++++- src/config.rs | 13 +++++++++++++ src/config/config_tests.rs | 31 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 8fa77eb9dd..7477eef46c 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -14,7 +14,7 @@ use deltachat::chat::{ marknoticed_chat, remove_contact_from_chat, Chat, ChatId, ChatItem, MessageListOptions, }; use deltachat::chatlist::Chatlist; -use deltachat::config::Config; +use deltachat::config::{get_all_ui_config_keys, Config}; use deltachat::constants::DC_MSG_ID_DAYMARKER; use deltachat::contact::{may_be_valid_addr, Contact, ContactId, Origin}; use deltachat::context::get_info; @@ -458,6 +458,12 @@ impl CommandApi { Ok(result) } + /// Returns all `ui.*` config keys that were set by the UI. + async fn get_all_ui_config_keys(&self, account_id: u32) -> Result> { + let ctx = self.get_context(account_id).await?; + get_all_ui_config_keys(&ctx).await + } + async fn set_stock_strings(&self, strings: HashMap) -> Result<()> { let accounts = self.accounts.read().await; for (stock_id, stock_message) in strings { diff --git a/src/config.rs b/src/config.rs index bdb5ca2b14..566e7e2cec 100644 --- a/src/config.rs +++ b/src/config.rs @@ -987,5 +987,18 @@ fn get_config_keys_string() -> String { format!(" {keys} ") } +/// Returns all `ui.*` config keys that were set by the UI. +pub async fn get_all_ui_config_keys(context: &Context) -> Result> { + let ui_keys = context + .sql + .query_map_vec( + "SELECT keyname FROM config WHERE keyname LIKE 'ui.%' ORDER BY config.id ASC", + (), + |row| Ok(row.get::<_, String>(0)?), + ) + .await?; + Ok(ui_keys) +} + #[cfg(test)] mod config_tests; diff --git a/src/config/config_tests.rs b/src/config/config_tests.rs index aabe0e7f5f..78481f2941 100644 --- a/src/config/config_tests.rs +++ b/src/config/config_tests.rs @@ -81,6 +81,37 @@ async fn test_ui_config() -> Result<()> { Ok(()) } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_get_all_ui_config_keys() -> Result<()> { + let t = TestContext::new().await; + + t.set_ui_config("ui.android.screen_security", Some("safe")) + .await?; + t.set_ui_config("ui.lastchatid", Some("231")).await?; + t.set_ui_config( + "ui.desktop.webxdcBounds.528490", + Some(r#"{"x":954,"y":356,"width":378,"height":671}"#), + ) + .await?; + t.set_ui_config( + "ui.desktop.webxdcBounds.556543", + Some(r#"{"x":954,"y":356,"width":378,"height":671}"#), + ) + .await?; + + assert_eq!( + get_all_ui_config_keys(&t).await?, + vec![ + "ui.android.screen_security", + "ui.lastchatid", + "ui.desktop.webxdcBounds.528490", + "ui.desktop.webxdcBounds.556543" + ] + ); + + Ok(()) +} + /// Regression test for https://github.com/deltachat/deltachat-core-rust/issues/3012 #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_set_config_bool() -> Result<()> { From 637b0c32cf490cbddf0f76f4eb844a4c85991d12 Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Sat, 13 Dec 2025 17:45:21 +0000 Subject: [PATCH 2/2] Update src/config.rs Co-authored-by: iequidoo <117991069+iequidoo@users.noreply.github.com> --- src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 566e7e2cec..3969c53e9f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -992,7 +992,7 @@ pub async fn get_all_ui_config_keys(context: &Context) -> Result> { let ui_keys = context .sql .query_map_vec( - "SELECT keyname FROM config WHERE keyname LIKE 'ui.%' ORDER BY config.id ASC", + "SELECT keyname FROM config WHERE keyname GLOB 'ui.*' ORDER BY config.id", (), |row| Ok(row.get::<_, String>(0)?), )