From 537592a5ac9017d4583677aed03ec26ee7141b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= Date: Tue, 22 Oct 2024 01:20:26 +0200 Subject: [PATCH] fix(appearance): clean up density message Makes the syncing of the dark and light modes use an already available function, rather than explicitly doing it inside the message. --- .../src/pages/desktop/appearance/mod.rs | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/cosmic-settings/src/pages/desktop/appearance/mod.rs b/cosmic-settings/src/pages/desktop/appearance/mod.rs index 1c463ef..21c0102 100644 --- a/cosmic-settings/src/pages/desktop/appearance/mod.rs +++ b/cosmic-settings/src/pages/desktop/appearance/mod.rs @@ -742,17 +742,18 @@ impl Page { _ = config.set("header_size", density); } - let spacing: Spacing = density.into(); + let Some(config) = self.theme_builder_config.as_ref() else { + return Command::none(); + }; - let light_config = Theme::light_config().ok(); - let dark_config = Theme::dark_config().ok(); + let spacing = density.into(); - // Update both light and dark theme configs - if let Some(config) = light_config { - _ = config.set("spacing", spacing); - } - if let Some(config) = dark_config { - _ = config.set("spacing", spacing); + if self + .theme_builder + .set_spacing(config, spacing) + .unwrap_or_default() + { + self.theme_config_write("spacing", spacing); } tokio::task::spawn(async move { @@ -1252,6 +1253,19 @@ impl Page { } } + if theme_builder.spacing != current_theme_builder.spacing { + if let Err(err) = + theme_builder.set_spacing(&other_builder_config, current_theme_builder.spacing) + { + tracing::error!(?err, "Error setting spacing"); + } + + if let Err(err) = theme.set_spacing(&other_theme_config, current_theme_builder.spacing) + { + tracing::error!(?err, "Error setting spacing"); + } + } + Ok(()) }