Skip to main content

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, IPC::SkyEvent::SkyEvent};
6use serde_json::json;
7use tauri::Emitter;
8
9use crate::dev_log;
10
11/// Reveals a specific item in the tree view by notifying the UI.
12pub(super) async fn reveal_tree_item(
13	env:&crate::Environment::MountainEnvironment::MountainEnvironment,
14
15	view_identifier:String,
16
17	item_handle:String,
18
19	options:serde_json::Value,
20) -> Result<(), CommonError> {
21	dev_log!(
22		"extensions",
23		"[TreeViewProvider] Revealing item '{}' in view '{}'",
24		item_handle,
25		view_identifier
26	);
27
28	env.ApplicationHandle
29		.emit(
30			SkyEvent::TreeViewReveal.AsStr(),
31			json!({ "viewId": view_identifier, "itemHandle": item_handle, "options": options }),
32		)
33		.map_err(|Error| CommonError::UserInterfaceInteraction { Reason:Error.to_string() })
34}
35
36/// Refreshes the tree view by notifying the UI.
37pub(super) async fn refresh_tree_view(
38	env:&crate::Environment::MountainEnvironment::MountainEnvironment,
39
40	view_identifier:String,
41
42	items_to_refresh:Option<serde_json::Value>,
43) -> Result<(), CommonError> {
44	dev_log!("extensions", "[TreeViewProvider] Refreshing view '{}'", view_identifier);
45
46	env.ApplicationHandle
47		.emit(
48			SkyEvent::TreeViewRefresh.AsStr(),
49			json!({ "viewId": view_identifier, "itemsToRefresh": items_to_refresh }),
50		)
51		.map_err(|Error| CommonError::UserInterfaceInteraction { Reason:Error.to_string() })
52}