Updates: opt-in launch check, Check for Updates…, install after a normal quit, from the Gitea release; dmgs carry an Applications link (UPD-1, REL-1)
This commit is contained in:
28 files changed
+896
-16
No files matched your search
@@ -38,6 +38,7 @@ pub const LANGUAGE: &str = "language";
|
||||
pub const MOTION: &str = "motion";
|
||||
pub const OMARCHY_SYNC: &str = "omarchy_sync";
|
||||
pub const AUTHOR: &str = "author";
|
||||
pub const CHECK_UPDATES: &str = "check_updates";
|
||||
|
||||
/// The shared settings; absent fields take their defaults.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@@ -48,6 +49,8 @@ pub struct Shared {
|
||||
pub omarchy_sync: bool,
|
||||
/// Signs comments and changes; empty means the account name.
|
||||
pub author: String,
|
||||
/// Asks for a newer release at launch; off unless chosen.
|
||||
pub check_updates: bool,
|
||||
}
|
||||
|
||||
impl Default for Shared {
|
||||
@@ -58,6 +61,7 @@ impl Default for Shared {
|
||||
motion: Motion::System,
|
||||
omarchy_sync: true,
|
||||
author: String::new(),
|
||||
check_updates: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +96,11 @@ impl Shared {
|
||||
appearance: pick(fields, APPEARANCE, &Appearance::ALL)?.unwrap_or(defaults.appearance),
|
||||
language: pick(fields, LANGUAGE, &Language::ALL)?.unwrap_or(defaults.language),
|
||||
motion: pick(fields, MOTION, &Motion::ALL)?.unwrap_or(defaults.motion),
|
||||
check_updates: match fields.get(CHECK_UPDATES) {
|
||||
None => defaults.check_updates,
|
||||
Some(Value::Bool(on)) => *on,
|
||||
Some(other) => return Err(wrong(CHECK_UPDATES, other)),
|
||||
},
|
||||
omarchy_sync: match fields.get(OMARCHY_SYNC) {
|
||||
None => defaults.omarchy_sync,
|
||||
Some(Value::Bool(on)) => *on,
|
||||
|
||||
@@ -63,14 +63,15 @@ fn shared_fields_type_strictly_and_default_when_absent() {
|
||||
let fields = |text: &str| serde_json::from_str::<serde_json::Map<_, _>>(text).unwrap();
|
||||
assert_eq!(Shared::from_fields(&fields("{}")).unwrap(), Shared::default());
|
||||
let read = Shared::from_fields(&fields(
|
||||
r#"{"appearance":"dark","language":"zh-CN","motion":"reduce","omarchy_sync":false,"author":" Ana "}"#,
|
||||
r#"{"appearance":"dark","language":"zh-CN","motion":"reduce","omarchy_sync":false,"author":" Ana ","check_updates":true}"#,
|
||||
))
|
||||
.unwrap();
|
||||
assert!(read.check_updates && !Shared::default().check_updates, "asked for, never by default");
|
||||
assert_eq!(
|
||||
(read.appearance, read.language, read.motion, read.omarchy_sync, read.author.as_str()),
|
||||
(Appearance::Dark, Language::Chinese, Motion::Reduced, false, "Ana")
|
||||
);
|
||||
for bad in [r#"{"appearance":"blue"}"#, r#"{"omarchy_sync":"yes"}"#, r#"{"author":3}"#] {
|
||||
for bad in [r#"{"appearance":"blue"}"#, r#"{"omarchy_sync":"yes"}"#, r#"{"author":3}"#, r#"{"check_updates":1}"#] {
|
||||
assert!(Shared::from_fields(&fields(bad)).is_err(), "{bad}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user