From 3f2ba11d56817dbcea2d62b8afd462aa9f8a3a3e Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Fri, 27 Dec 2024 20:45:13 -0500 Subject: [PATCH] refactor: send initial config after watching for changes --- cosmic-config/src/dbus.rs | 44 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/cosmic-config/src/dbus.rs b/cosmic-config/src/dbus.rs index dd0612c8..c1808e35 100644 --- a/cosmic-config/src/dbus.rs +++ b/cosmic-config/src/dbus.rs @@ -86,27 +86,6 @@ fn watcher_stream config, - Err((errors, default)) => { - if !errors.is_empty() { - eprintln!("Error getting config: {config_id} {errors:?}"); - } - default - } - }; - - if let Err(err) = tx - .send(Update { - errors: Vec::new(), - keys: Vec::new(), - config: config.clone(), - }) - .await - { - eprintln!("Failed to send config: {err}"); - } - let mut attempts = 0; loop { @@ -168,6 +147,29 @@ fn watcher_stream config, + Err((errors, default)) => { + if !errors.is_empty() { + eprintln!("Error getting config: {config_id} {errors:?}"); + } + default + } + }; + + if let Err(err) = tx + .send(Update { + errors: Vec::new(), + keys: Vec::new(), + config: config.clone(), + }) + .await + { + eprintln!("Failed to send config: {err}"); + } + loop { let change: Changed = futures::select! { c = changes.next() => {