Skip to main content

Mountain/Environment/StatusBarProvider/
MessageManagement.rs

1//! # StatusBarProvider - Message Management
2//!
3//! Implementation of status bar temporary message handling for
4//! [`MountainEnvironment`]
5
6use CommonLibrary::{Error::CommonError::CommonError, IPC::SkyEvent::SkyEvent};
7use serde_json::{Value, json};
8use tauri::Emitter;
9
10use super::super::MountainEnvironment::MountainEnvironment;
11use crate::dev_log;
12
13/// Message management operations implementation for MountainEnvironment
14pub(super) async fn set_status_bar_message_impl(
15	env:&MountainEnvironment,
16	message_identifier:String,
17	text:String,
18) -> Result<(), CommonError> {
19	dev_log!(
20		"lifecycle",
21		"[StatusBarProvider] Setting status message '{}': {}",
22		message_identifier,
23		text
24	);
25
26	env.ApplicationHandle
27		.emit::<Value>(
28			SkyEvent::StatusBarSetMessage.AsStr(),
29			json!({ "id": message_identifier, "text": text }),
30		)
31		.map_err(|error| CommonError::UserInterfaceInteraction { Reason:error.to_string() })
32}
33
34/// Disposes of a temporary status bar message.
35pub(super) async fn dispose_status_bar_message_impl(
36	env:&MountainEnvironment,
37	message_identifier:String,
38) -> Result<(), CommonError> {
39	dev_log!(
40		"lifecycle",
41		"[StatusBarProvider] Disposing status message '{}'",
42		message_identifier
43	);
44
45	env.ApplicationHandle
46		.emit::<Value>(SkyEvent::StatusBarDisposeMessage.AsStr(), json!({ "id": message_identifier }))
47		.map_err(|error| CommonError::UserInterfaceInteraction { Reason:error.to_string() })
48}