MCPcopy Create free account
hub / github.com/Moosync/Moosync / initial

Function initial

src-tauri/src/preference_holder/mod.rs:118–173  ·  view source on GitHub ↗
(app: &mut App)

Source from the content-addressed store, hash-verified

116
117#[tracing::instrument(level = "debug", skip(app))]
118pub fn initial(app: &mut App) {
119 let pref_config: State<PreferenceConfig> = app.state();
120 if !pref_config.has_key("thumbnail_path") {
121 let path = app.path().app_local_data_dir().unwrap().join("thumbnails");
122 let _ = pref_config.save_selective("thumbnail_path".to_string(), Some(path));
123 }
124
125 if !pref_config.has_key("artwork_path") {
126 let path = app.path().app_local_data_dir().unwrap().join("artwork");
127 let _ = pref_config.save_selective("artwork_path".to_string(), Some(path));
128 }
129
130 if !pref_config.has_key("i18n_language") {
131 let _ = pref_config.save_selective(
132 "i18n_language".to_string(),
133 Some(
134 [
135 "af_ZA", "ar_SA", "ca_ES", "cs_CZ", "da_DK", "de_DE", "el_GR", "en_US",
136 "es_ES", "fi_FI", "fr_FR", "he_IL", "hi_IN", "hu_HU", "it_IT", "ja_JP",
137 "ko_KR", "nl_NL", "no_NO", "pl_PL", "pt_BR", "pt_PT", "ro_RO", "ru_RU",
138 "sr_SP", "sv_SE", "tr_TR", "uk_UA", "vi_VN", "zh_CN", "zh_TW",
139 ]
140 .into_iter()
141 .map(|locale| CheckboxPreference {
142 key: locale.to_string(),
143 enabled: locale == "en_US",
144 })
145 .collect::<Vec<_>>(),
146 ),
147 );
148 }
149
150 // Spawn scan task
151 let scan_task: State<ScanTask> = app.state();
152 let scan_duration = pref_config.load_selective::<u64>("scan_interval".into());
153 if let Ok(scan_duration) = scan_duration {
154 scan_task.spawn_scan_task(app.handle().clone(), scan_duration.max(30));
155 } else {
156 tracing::warn!("Could not spawn scan task, no / invalid duration found");
157 }
158
159 let handle = app.handle().clone();
160 tauri::async_runtime::spawn(async move {
161 let extension_handler = handle.state::<ExtensionHandler>();
162 if let Err(e) = extension_handler.find_new_extensions().await {
163 tracing::error!("Failed to find extensions: {:?}", e);
164 }
165 });
166
167 let handle = app.handle().clone();
168 tauri::async_runtime::spawn_blocking(move || {
169 if let Err(e) = start_scan(handle, None) {
170 tracing::error!("Failed to scan: {:?}", e);
171 }
172 });
173}
174
175generate_command!(load_selective, PreferenceConfig, Value, key: String);

Callers 1

runFunction · 0.85

Calls 6

start_scanFunction · 0.85
has_keyMethod · 0.80
save_selectiveMethod · 0.80
spawn_scan_taskMethod · 0.80
cloneMethod · 0.80
find_new_extensionsMethod · 0.80

Tested by

no test coverage detected