Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/UI/
NotificationShowProgress.rs

1//! Wire method: `notification:showProgress`.
2
3use serde_json::{Value, json};
4use tauri::{AppHandle, Emitter};
5use CommonLibrary::IPC::SkyEvent::SkyEvent;
6
7use crate::IPC::WindServiceHandlers::Utilities::JsonValueHelpers::{arg_bool, arg_string};
8
9fn NewId() -> String {
10	use std::sync::atomic::{AtomicU64, Ordering};
11
12	static SEQ:AtomicU64 = AtomicU64::new(1);
13
14	format!("progress-{}", SEQ.fetch_add(1, Ordering::Relaxed))
15}
16
17pub async fn Fn(ApplicationHandle:AppHandle, Arguments:Vec<Value>) -> Result<Value, String> {
18	let Title = arg_string(&Arguments, 0);
19
20	let Cancellable = arg_bool(&Arguments, 1);
21
22	let Id = NewId();
23
24	let _ = ApplicationHandle.emit(
25		SkyEvent::NotificationProgressBegin.AsStr(),
26		json!({
27			"id": Id,
28			"title": Title,
29			"cancellable": Cancellable,
30		}),
31	);
32
33	Ok(json!(Id))
34}