settings: Remove auxiliary Content types where possible (#16744)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-10 22:59:10 -04:00 committed by GitHub
parent 8f28445612
commit ccf6f27b8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 843 additions and 696 deletions

View file

@ -116,27 +116,30 @@ impl Drop for MacOsUnmounter {
}
}
/// Whether or not to automatically check for updates.
#[derive(Clone, Copy, JsonSchema, Deserialize, Serialize)]
#[serde(default)]
#[serde(transparent)]
struct AutoUpdateSetting(bool);
/// Whether or not to automatically check for updates.
///
/// Default: true
#[derive(Clone, Copy, Default, JsonSchema, Deserialize, Serialize)]
#[serde(transparent)]
struct AutoUpdateSettingContent(bool);
impl Default for AutoUpdateSetting {
fn default() -> Self {
Self(true)
}
}
impl Settings for AutoUpdateSetting {
const KEY: Option<&'static str> = Some("auto_update");
type FileContent = Option<AutoUpdateSettingContent>;
type FileContent = Self;
fn load(sources: SettingsSources<Self::FileContent>, _: &mut AppContext) -> Result<Self> {
let auto_update = [sources.release_channel, sources.user]
.into_iter()
.find_map(|value| value.copied().flatten())
.unwrap_or(sources.default.ok_or_else(Self::missing_default)?);
.find_map(|value| value.copied())
.unwrap_or(*sources.default);
Ok(Self(auto_update.0))
Ok(auto_update)
}
}