Add system notifications for track changes

- Add notify-rust dependency for desktop notifications
- Create notification.rs commands module with show_track_notification and show_notification
- Register notification commands in lib.rs
- Wire up notifications in frontend for all playback scenarios:
  - Search results playback
  - Album track playback
  - Playlist track playback
  - Queue navigation and auto-advance
This commit is contained in:
vicrodh committed 2026-01-09 11:04:03 -06:00
1 parent ddbedf6ab0
commit ef8feebc45
5 files changed
+101

No files matched your search

+2
View File
@@ -4,6 +4,7 @@
pub mod auth;
pub mod favorites;
pub mod notification;
pub mod playback;
pub mod playlist;
pub mod queue;
@@ -11,6 +12,7 @@ pub mod search;
pub use auth::*;
pub use favorites::*;
pub use notification::*;
pub use playback::*;
pub use playlist::*;
pub use queue::*;
+52
View File
@@ -0,0 +1,52 @@
//! System notification commands
use notify_rust::Notification;
/// Show a track change notification
#[tauri::command]
pub fn show_track_notification(
title: String,
artist: String,
album: String,
_artwork_url: Option<String>,
) -> Result<(), String> {
log::info!("Command: show_track_notification - {} by {}", title, artist);
let body = if album.is_empty() {
artist.clone()
} else {
format!("{} • {}", artist, album)
};
Notification::new()
.summary(&title)
.body(&body)
.appname("QBZ")
.timeout(3000) // 3 seconds
.show()
.map_err(|e| format!("Failed to show notification: {}", e))?;
Ok(())
}
/// Show a generic notification
#[tauri::command]
pub fn show_notification(
title: String,
body: Option<String>,
) -> Result<(), String> {
log::info!("Command: show_notification - {}", title);
let mut notification = Notification::new();
notification.summary(&title).appname("QBZ").timeout(3000);
if let Some(body_text) = body {
notification.body(&body_text);
}
notification
.show()
.map_err(|e| format!("Failed to show notification: {}", e))?;
Ok(())
}