Mountain/Environment/OutputProvider/
ChannelVisibility.rs

1//! # Output Channel Visibility Helpers
2//!
3//! Internal helper functions for output channel UI visibility operations.
4//! These are not public API - they are called by the main provider
5//! implementation.
6
7use CommonLibrary::Error::CommonError::CommonError;
8use log::{info, warn};
9use serde_json::json;
10use tauri::Emitter;
11
12use crate::Environment::Utility;
13
14/// Reveals an output channel in the UI.
15pub(super) async fn reveal_channel(
16	env:&crate::Environment::MountainEnvironment::MountainEnvironment,
17	channel_identifier:String,
18	preserve_focus:bool,
19) -> Result<(), CommonError> {
20	info!("[OutputProvider] Revealing channel: '{}'", channel_identifier);
21
22	let mut channels_guard = env
23		.ApplicationState
24		.Feature
25		.OutputChannels
26		.OutputChannels
27		.lock()
28		.map_err(Utility::MapApplicationStateLockErrorToCommonError)?;
29
30	if let Some(channel_state) = channels_guard.get_mut(&channel_identifier) {
31		channel_state.IsVisible = true;
32
33		let event_payload = json!({ "Id": channel_identifier, "PreserveFocus": preserve_focus });
34
35		env.ApplicationHandle
36			.emit("sky://output/reveal", event_payload)
37			.map_err(|Error| CommonError::UserInterfaceInteraction { Reason:Error.to_string() })?;
38	} else {
39		warn!("[OutputProvider] Channel '{}' not found for reveal.", channel_identifier);
40	}
41
42	Ok(())
43}
44
45/// Closes the view of an output channel in the UI.
46pub(super) async fn close_channel(
47	_env:&crate::Environment::MountainEnvironment::MountainEnvironment,
48	_channel_identifier:String,
49) -> Result<(), CommonError> {
50	warn!("[OutputProvider] Close is not fully implemented.");
51
52	Ok(())
53}