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	let Title = Parameter.get("title").and_then(Value::as_str).unwrap_or("");
16	let Cancellable = Parameter.get("cancellable").and_then(Value::as_bool).unwrap_or(false);
17	if let Err(Error) = Service.ApplicationHandle().emit(
18		"sky://notification/progress-begin",
19		json!({
20			"id": Handle,
21			"title": Title,
22			"cancellable": Cancellable,
23		}),
24	) {
25		dev_log!(
26			"grpc",
27			"warn: [MountainVinegRPCService] sky://notification/progress-begin emit failed: {}",
28			Error
29		);
30	}
31}