Mountain/Environment/TreeViewProvider/
Visibility.rs

1//! # Tree View Visibility Helpers
2//!
3//! Internal helper functions for tree view visibility and refresh operations.
4
5use CommonLibrary::Error::CommonError::CommonError;
6use log::info;
7use serde_json::json;
8use tauri::Emitter;
9
10use crate::Environment::Utility;
11
12/// Reveals a specific item in the tree view by notifying the UI.
13pub(super) async fn reveal_tree_item(
14	env:&crate::Environment::MountainEnvironment::MountainEnvironment,
15	view_identifier:String,
16	item_handle:String,
17	options:serde_json::Value,
18) -> Result<(), CommonError> {
19	info!(
20		"[TreeViewProvider] Revealing item '{}' in view '{}'",
21		item_handle, view_identifier
22	);
23
24	env.ApplicationHandle
25		.emit(
26			"sky://tree-view/reveal",
27			json!({ "viewId": view_identifier, "itemHandle": item_handle, "options": options }),
28		)
29		.map_err(|Error| CommonError::UserInterfaceInteraction { Reason:Error.to_string() })
30}
31
32/// Refreshes the tree view by notifying the UI.
33pub(super) async fn refresh_tree_view(
34	env:&crate::Environment::MountainEnvironment::MountainEnvironment,
35	view_identifier:String,
36	items_to_refresh:Option<serde_json::Value>,
37) -> Result<(), CommonError> {
38	info!("[TreeViewProvider] Refreshing view '{}'", view_identifier);
39
40	env.ApplicationHandle
41		.emit(
42			"sky://tree-view/refresh",
43			json!({ "viewId": view_identifier, "itemsToRefresh": items_to_refresh }),
44		)
45		.map_err(|Error| CommonError::UserInterfaceInteraction { Reason:Error.to_string() })
46}