Mountain/IPC/WindServiceHandlers/UI/
ProgressBegin.rs1#![allow(unused_variables)]
2
3use serde_json::{Value, json};
6use tauri::{AppHandle, Emitter};
7use CommonLibrary::IPC::SkyEvent::SkyEvent;
8
9fn NewProgressId() -> String {
10 format!(
11 "progress-{}",
12 std::time::SystemTime::now()
13 .duration_since(std::time::UNIX_EPOCH)
14 .map(|D| D.as_millis())
15 .unwrap_or(0)
16 )
17}
18
19pub async fn Fn(ApplicationHandle:AppHandle, Arguments:Vec<Value>) -> Result<Value, String> {
20 let Location = Arguments.first().and_then(|V| V.as_str()).unwrap_or("notification").to_string();
21
22 let Title = Arguments.get(1).and_then(|V| V.as_str()).unwrap_or("").to_string();
23
24 let Cancellable = Arguments.get(2).and_then(|V| V.as_bool()).unwrap_or(false);
25
26 let Id = NewProgressId();
27
28 let _ = ApplicationHandle.emit(
29 SkyEvent::ProgressBegin.AsStr(),
30 json!({
31 "id": Id,
32 "location": Location,
33 "title": Title,
34 "cancellable": Cancellable,
35 }),
36 );
37
38 Ok(json!(Id))
39}