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 _State:State<'_, Arc<ApplicationState>>,
24 ViewId:String,
25 ItemHandle:String,
26 Options:Option<Value>,
27) -> Result<Value, String> {
28 dev_log!("commands", "revealing item '{}' in view '{}'", ItemHandle, ViewId);
29
30 let RunTime = ApplicationHandle.state::<Arc<ApplicationRunTime>>().inner().clone();
31 let Environment:Arc<MountainEnvironment> = RunTime.Environment.clone();
32 let OptionsValue = Options.unwrap_or(json!({}));
33
34 match Environment.RevealTreeItem(ViewId.clone(), ItemHandle, OptionsValue).await {
35 Ok(_) => Ok(json!({ "success": true })),
36 Err(Error) => {
37 let ErrorMessage = format!("Failed to reveal tree item in view '{}': {}", ViewId, Error);
38 dev_log!("commands", "error: {}", ErrorMessage);
39 Err(ErrorMessage)
40 },
41 }
42}