Skip to content

Commit

Permalink
fix(appearance): clean up density message
Browse files Browse the repository at this point in the history
Makes the syncing of the dark and light modes use an already available function, rather than explicitly doing it inside the message.
  • Loading branch information
git-f0x committed Oct 21, 2024
1 parent 2a76db4 commit fd77ea3
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions cosmic-settings/src/pages/desktop/appearance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(())
}

Expand Down

0 comments on commit fd77ea3

Please sign in to comment.