feat(control): add notification for automatic resume from pause state

This commit is contained in:
Alexandr Stelnykovych
2025-11-11 17:18:58 +02:00
parent 3406017754
commit 3abb2b3c69
2 changed files with 32 additions and 2 deletions

View File

@@ -423,7 +423,7 @@ pub async fn tray_handler(cli: PortAPI, app: tauri::AppHandle) {
Ok(rx) => rx, Ok(rx) => rx,
Err(err) => { Err(err) => {
error!( error!(
"cancel try_handler: failed to subscribe to 'runtime:subsystems': {}", "cancel try_handler: failed to subscribe to 'runtime:system/status': {}",
err err
); );
return; return;
@@ -594,7 +594,18 @@ pub async fn tray_handler(cli: PortAPI, app: tauri::AppHandle) {
} }
} }
} }
update_icon_nostate(icon.clone());
}
pub fn update_icon_nostate(icon: AppIcon) {
update_icon_color(&icon, IconColor::Red); update_icon_color(&icon, IconColor::Red);
if let Ok(menu) = build_tray_menu(icon.app_handle(), "unknown", "unknown", &system_status_types::PauseInfo::default()) {
if let Err(err) = icon.set_menu(Some(menu)) {
error!("failed to set menu on tray icon: {}", err.to_string());
}
}
} }
fn update_icon_color(icon: &AppIcon, new_color: IconColor) { fn update_icon_color(icon: &AppIcon, new_color: IconColor) {

View File

@@ -155,7 +155,26 @@ func (c *Control) startResumeWorker(duration time.Duration) {
} }
case <-time.After(duration): case <-time.After(duration):
wc.Info("Resuming...") wc.Info("Resuming...")
return c.resume()
err := c.resume()
if err == nil {
n := &notifications.Notification{
EventID: "control:resumed",
Type: notifications.Info,
Title: "Resumed",
Message: "Automatically resumed from pause state",
ShowOnSystem: true,
Expires: time.Now().Add(15 * time.Second).Unix(),
AvailableActions: []*notifications.Action{
{
ID: "ack",
Text: "OK",
},
},
}
notifications.Notify(n)
}
return err
} }
} }
} }