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

Function get_theme_handler_state

src-tauri/src/themes/mod.rs:27–47  ·  view source on GitHub ↗
(app: &mut App)

Source from the content-addressed store, hash-verified

25
26#[tracing::instrument(level = "debug", skip(app))]
27pub fn get_theme_handler_state(app: &mut App) -> ThemeHolder {
28 let path = app.path().app_local_data_dir().unwrap().join("themes");
29 if !path.exists() {
30 fs::create_dir_all(path.clone()).unwrap();
31 }
32
33 let tmp_dir = app.path().temp_dir().unwrap();
34
35 let (tx, rx) = channel();
36
37 let app_handle = app.app_handle().clone();
38 tauri::async_runtime::spawn(async move {
39 while let Ok(event) = rx.recv() {
40 if let Err(e) = app_handle.emit("theme-updated", event) {
41 tracing::error!("Failed to emit theme_updated event: {:?}", e);
42 }
43 }
44 });
45
46 ThemeHolder::new(path, tmp_dir, tx)
47}
48
49#[tracing::instrument(level = "debug", skip(app, theme_handler, window_handler))]
50#[tauri::command(async)]

Callers 1

runFunction · 0.85

Calls 2

cloneMethod · 0.80
emitMethod · 0.80

Tested by

no test coverage detected