Skip to main content

Mountain/Vine/Server/Notification/
ProgressStart.rs

1#![allow(non_snake_case)]
2//! Cocoon → Mountain `progress.start` notification.
3//! Fires at the top of every `vscode.window.withProgress(...)` call.
4//! Normalises onto `sky://notification/progress-begin` so Sky's progress
5//! indicator renders identically whether an extension or a Mountain
6//! handler triggered the progress.
7
8use serde_json::{Value, json};
9use tauri::Emitter;
10
11use crate::{Vine::Server::MountainVinegRPCService::MountainVinegRPCService, dev_log};
12
13pub async fn ProgressStart(Service:&MountainVinegRPCService, Parameter:&Value) {
14	let Handle = Parameter.get("handle").and_then(Value::as_str).unwrap_or("");
15
16	let Title = Parameter.get("title").and_then(Value::as_str).unwrap_or("");
17
18	let Cancellable = Parameter.get("cancellable").and_then(Value::as_bool).unwrap_or(false);
19
20	if let Err(Error) = Service.ApplicationHandle().emit(
21		"sky://notification/progress-begin",
22		json!({
23			"id": Handle,
24			"title": Title,
25			"cancellable": Cancellable,
26		}),
27	) {
28		dev_log!(
29			"grpc",
30			"warn: [MountainVinegRPCService] sky://notification/progress-begin emit failed: {}",
31			Error
32		);
33	}
34}