Skip to content

Commit eb70aaf

Browse files
committed
feat: aw-notify-rs specifies notification titles
1 parent 631f958 commit eb70aaf

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

src-tauri/src/manager.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,17 @@ fn handle(rx: Receiver<ModuleMessage>, state: Arc<Mutex<ManagerState>>) {
418418

419419
if should_restart {
420420
if let Some((secs, restart_count)) = restart_info {
421-
// Show dialog BEFORE sleeping
422-
let app =
423-
&*get_app_handle().lock().expect("Failed to get app handle");
424-
app.dialog()
425-
.message(format!("{name_clone} crashed. Restarting..."))
426-
.kind(MessageDialogKind::Warning)
427-
.title("Warning")
428-
.show(|_| {});
421+
{
422+
// Show dialog BEFORE sleeping
423+
let app = &*get_app_handle()
424+
.lock()
425+
.expect("Failed to get app handle");
426+
app.dialog()
427+
.message(format!("{name_clone} crashed. Restarting..."))
428+
.kind(MessageDialogKind::Warning)
429+
.title("Warning")
430+
.show(|_| {});
431+
}
429432
error!("Module {name_clone} crashed and will be restarted");
430433

431434
thread::sleep(Duration::from_secs(secs));
@@ -753,9 +756,8 @@ fn start_notify_module_thread(
753756
notification.get("title").and_then(|t| t.as_str()),
754757
notification.get("message").and_then(|m| m.as_str()),
755758
) {
756-
// Format notification: "title\nmessage"
757-
let content = format!("{}\n{}", title, message);
758-
send_notification(&content);
759+
// Send notification with actual title from JSON
760+
send_notification(title, message);
759761
debug!(
760762
"Parsed JSON notification: title='{}', message length={}",
761763
title,
@@ -796,22 +798,23 @@ fn start_notify_module_thread(
796798
});
797799
}
798800

799-
fn send_notification(content: &str) {
801+
fn send_notification(title: &str, message: &str) {
800802
// Get app handle and send notification
801803
if let Ok(app_handle_guard) = get_app_handle().lock() {
802804
let app_handle = &*app_handle_guard;
803805
let result = app_handle
804806
.notification()
805807
.builder()
806-
.title("ActivityWatch")
807-
.body(content)
808+
.title(title)
809+
.body(message)
808810
.show();
809811

810812
match result {
811813
Ok(_) => {
812814
trace!(
813-
"Sent notification: {}",
814-
content.lines().next().unwrap_or("")
815+
"Sent notification: title='{}', message preview='{}'",
816+
title,
817+
message.lines().next().unwrap_or("")
815818
);
816819
}
817820
Err(e) => {

0 commit comments

Comments
 (0)