| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
use quasi_declare::declare; |
| 42 |
use quasi_router::screen::Choice; |
| 43 |
use quasi_router::{Action, RouteError}; |
| 44 |
|
| 45 |
use crate::commands::Preferences; |
| 46 |
use crate::state::AppState; |
| 47 |
|
| 48 |
|
| 49 |
pub(super) const UPDATE_CHECK: &str = "update_check_on_launch"; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
struct Fact { |
| 56 |
|
| 57 |
label: &'static str, |
| 58 |
|
| 59 |
value: &'static str, |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
const FIXED: &[Fact] = &[ |
| 64 |
Fact { |
| 65 |
label: "Publisher", |
| 66 |
value: "Make Creative, LLC", |
| 67 |
}, |
| 68 |
Fact { |
| 69 |
label: "License", |
| 70 |
value: "PolyForm Noncommercial 1.0.0", |
| 71 |
}, |
| 72 |
Fact { |
| 73 |
label: "Contact", |
| 74 |
value: "info@makenot.work", |
| 75 |
}, |
| 76 |
Fact { |
| 77 |
label: "Source", |
| 78 |
value: "makenot.work", |
| 79 |
}, |
| 80 |
Fact { |
| 81 |
label: "Privacy", |
| 82 |
value: "makenot.work/policy", |
| 83 |
}, |
| 84 |
]; |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
fn update_choice(prefs: &Preferences) -> &'static str { |
| 92 |
if prefs.update_check_on_launch { |
| 93 |
"enabled" |
| 94 |
} else { |
| 95 |
"disabled" |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
declare! { |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
pub(super) shape pane(state: &AppState) -> Vec<Node>; |
| 112 |
|
| 113 |
let prefs = read(state); |
| 114 |
|
| 115 |
section "About GoingsOn"; |
| 116 |
text "Tasks, email, calendar, contacts."; |
| 117 |
|
| 118 |
list { |
| 119 |
|
| 120 |
|
| 121 |
row "Version" { |
| 122 |
meta state.about.version.clone(); |
| 123 |
} |
| 124 |
row "Platform" { |
| 125 |
meta state.about.platform.clone(); |
| 126 |
} |
| 127 |
for fact in FIXED { |
| 128 |
row fact.label { |
| 129 |
meta fact.value; |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
field Select UPDATE_CHECK "Check for updates on launch" { |
| 135 |
option Choice::new("enabled", "Enabled (default)"); |
| 136 |
option Choice::new("disabled", "Disabled"); |
| 137 |
value update_choice(&prefs); |
| 138 |
hint "When a new signed release is available, a banner appears in the app. \ |
| 139 |
Install is always user-initiated."; |
| 140 |
writes Action::post("/settings/about/update-check"); |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
fn read(state: &AppState) -> Preferences { |
| 146 |
state |
| 147 |
.config_dir |
| 148 |
.as_ref() |
| 149 |
.map_or_else(Preferences::default, |dir| { |
| 150 |
crate::commands::load_at(&crate::commands::path_in(dir)) |
| 151 |
}) |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
pub(super) fn write(state: &AppState, on: bool) -> Result<&'static str, RouteError> { |
| 160 |
let Some(dir) = state.config_dir.as_ref() else { |
| 161 |
return Err(RouteError::internal( |
| 162 |
"This machine did not give the app a config directory, so the setting cannot be saved.", |
| 163 |
)); |
| 164 |
}; |
| 165 |
let path = crate::commands::path_in(dir); |
| 166 |
let mut prefs = crate::commands::load_at(&path); |
| 167 |
prefs.update_check_on_launch = on; |
| 168 |
crate::commands::save_at(&path, &prefs) |
| 169 |
.map_err(|error| RouteError::internal(error.to_string()))?; |
| 170 |
Ok(if on { |
| 171 |
"Update checks on." |
| 172 |
} else { |
| 173 |
"Update checks off." |
| 174 |
}) |
| 175 |
} |
| 176 |
|
| 177 |
#[cfg(test)] |
| 178 |
mod tests; |
| 179 |
|