Mountain/Environment/OutputProvider/
ChannelVisibility.rs1use CommonLibrary::Error::CommonError::CommonError;
8use log::{info, warn};
9use serde_json::json;
10use tauri::Emitter;
11
12use crate::Environment::Utility;
13
14pub(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
45pub(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}