Mountain/Command/TreeView/
RevealTreeViewItem.rs1#![allow(non_snake_case)]
2
3use std::sync::Arc;
8
9use CommonLibrary::TreeView::TreeViewProvider::TreeViewProvider;
10use serde_json::{Value, json};
11use tauri::{AppHandle, Manager, State, Wry, command};
12
13use crate::{
14 ApplicationState::State::ApplicationState::ApplicationState,
15 Environment::MountainEnvironment::MountainEnvironment,
16 RunTime::ApplicationRunTime::ApplicationRunTime,
17 dev_log,
18};
19
20#[command]
21pub async fn RevealTreeViewItem(
22 ApplicationHandle:AppHandle<Wry>,
23
24 _State:State<'_, Arc<ApplicationState>>,
25
26 ViewId:String,
27
28 ItemHandle:String,
29
30 Options:Option<Value>,
31) -> Result<Value, String> {
32 dev_log!("commands", "revealing item '{}' in view '{}'", ItemHandle, ViewId);
33
34 let RunTime = ApplicationHandle.state::<Arc<ApplicationRunTime>>().inner().clone();
35
36 let Environment:Arc<MountainEnvironment> = RunTime.Environment.clone();
37
38 let OptionsValue = Options.unwrap_or(json!({}));
39
40 match Environment.RevealTreeItem(ViewId.clone(), ItemHandle, OptionsValue).await {
41 Ok(_) => Ok(json!({ "success": true })),
42
43 Err(Error) => {
44 let ErrorMessage = format!("Failed to reveal tree item in view '{}': {}", ViewId, Error);
45
46 dev_log!("commands", "error: {}", ErrorMessage);
47
48 Err(ErrorMessage)
49 },
50 }
51}