diff --git a/espanso-ui/src/mac/mod.rs b/espanso-ui/src/mac/mod.rs index 4570e20..b6c8569 100644 --- a/espanso-ui/src/mac/mod.rs +++ b/espanso-ui/src/mac/mod.rs @@ -235,7 +235,7 @@ impl From for Option { UI_EVENT_TYPE_CONTEXT_MENU_CLICK => { return Some(UIEvent::ContextMenuClick(raw.context_menu_id)); } - UI_EVENT_TYPE_HEARTBEAT => { + UI_EVENT_TYPE_HEARTBEAT => { return Some(UIEvent::Heartbeat); } _ => {} diff --git a/espanso-ui/src/menu.rs b/espanso-ui/src/menu.rs index a6da3f0..7d66312 100644 --- a/espanso-ui/src/menu.rs +++ b/espanso-ui/src/menu.rs @@ -58,26 +58,28 @@ mod tests { #[test] fn test_context_menu_serializes_correctly() { - let menu = Menu { items: vec![ - MenuItem::Simple(SimpleMenuItem { - id: 0, - label: "Open".to_string() - }), - MenuItem::Separator, - MenuItem::Sub(SubMenuItem { - label: "Sub".to_string(), - items: vec![ - MenuItem::Simple(SimpleMenuItem { - label: "Sub 1".to_string(), - id: 1, - }), - MenuItem::Simple(SimpleMenuItem { - label: "Sub 2".to_string(), - id: 2, - }), - ], - }), - ]}; + let menu = Menu { + items: vec![ + MenuItem::Simple(SimpleMenuItem { + id: 0, + label: "Open".to_string(), + }), + MenuItem::Separator, + MenuItem::Sub(SubMenuItem { + label: "Sub".to_string(), + items: vec![ + MenuItem::Simple(SimpleMenuItem { + label: "Sub 1".to_string(), + id: 1, + }), + MenuItem::Simple(SimpleMenuItem { + label: "Sub 2".to_string(), + id: 2, + }), + ], + }), + ], + }; assert_eq!( menu.to_json().unwrap(), diff --git a/espanso-ui/src/win32/notification.rs b/espanso-ui/src/win32/notification.rs index cb86d87..40d2cf3 100644 --- a/espanso-ui/src/win32/notification.rs +++ b/espanso-ui/src/win32/notification.rs @@ -17,14 +17,20 @@ * along with espanso. If not, see . */ -use std::{path::{PathBuf}, sync::{Arc, Mutex, mpsc::{Sender, channel}}}; +use std::{ + path::PathBuf, + sync::{ + mpsc::{channel, Sender}, + Arc, Mutex, + }, +}; -use anyhow::{Result, anyhow, bail}; +use anyhow::{anyhow, bail, Result}; use lazy_static::lazy_static; use log::{error, warn}; +use std::os::windows::process::CommandExt; use std::process::Command; use winrt_notification::{IconCrop, Toast}; -use std::os::windows::process::CommandExt; const ESPANSO_APP_USER_MODEL_ID: &str = "{5E3B6C0F-1A4D-45C4-8872-D8174702101A}"; @@ -34,9 +40,11 @@ lazy_static! { pub fn initialize_notification_thread(notification_icon_path: PathBuf) -> Result<()> { let (sender, receiver) = channel::(); - + { - let mut lock = SEND_CHANNEL.lock().map_err(|e| anyhow!("failed to define shared notification sender: {}", e))?; + let mut lock = SEND_CHANNEL + .lock() + .map_err(|e| anyhow!("failed to define shared notification sender: {}", e))?; *lock = Some(sender); } @@ -68,12 +76,14 @@ pub fn initialize_notification_thread(notification_icon_path: PathBuf) -> Result } pub fn show_notification(msg: &str) -> Result<()> { - let mut lock = SEND_CHANNEL.lock().map_err(|e| anyhow!("unable to acquire notification send channel: {}", e))?; + let mut lock = SEND_CHANNEL + .lock() + .map_err(|e| anyhow!("unable to acquire notification send channel: {}", e))?; match &mut *lock { Some(sender) => { sender.send(msg.to_string())?; Ok(()) - }, + } None => bail!("notification sender not available"), } } @@ -99,4 +109,4 @@ fn is_espanso_app_user_model_id_set() -> bool { false } } -} \ No newline at end of file +}