Skip to main content

Mountain/IPC/StatusReporter/
mountain_start_ipc_status_reporting.rs

1#![allow(non_snake_case)]
2
3//! `mountain_start_ipc_status_reporting` Tauri command - kick
4//! off the periodic Sky-emit loop with `interval_seconds`
5//! between snapshots.
6
7use tauri::Manager;
8
9use crate::{IPC::StatusReporter::Reporter::Struct as Reporter, dev_log};
10
11#[tauri::command]
12pub async fn mountain_start_ipc_status_reporting(
13	app_handle:tauri::AppHandle,
14	interval_seconds:u64,
15) -> Result<serde_json::Value, String> {
16	dev_log!("lifecycle", "Tauri command: start_ipc_status_reporting");
17
18	if let Some(reporter) = app_handle.try_state::<Reporter>() {
19		reporter
20			.start_periodic_reporting(interval_seconds)
21			.await
22			.map(|_| serde_json::json!({ "status": "started", "interval_seconds": interval_seconds }))
23	} else {
24		Err("StatusReporter not found in application state".to_string())
25	}
26}