Skip to main content

Mountain/IPC/WindServiceHandlers/UI/
NotificationShowProgress.rs

1#![allow(unused_variables)]
2
3//! Wire method: `notification:showProgress`.
4
5use serde_json::{Value, json};
6use tauri::{AppHandle, Emitter};
7use CommonLibrary::IPC::SkyEvent::SkyEvent;
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 = Arguments.first().and_then(|V| V.as_str()).unwrap_or("").to_string();
19
20	let Cancellable = Arguments.get(1).and_then(|V| V.as_bool()).unwrap_or(false);
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}