feat(control): add notification for automatic resume from pause state
This commit is contained in:
@@ -423,7 +423,7 @@ pub async fn tray_handler(cli: PortAPI, app: tauri::AppHandle) {
|
||||
Ok(rx) => rx,
|
||||
Err(err) => {
|
||||
error!(
|
||||
"cancel try_handler: failed to subscribe to 'runtime:subsystems': {}",
|
||||
"cancel try_handler: failed to subscribe to 'runtime:system/status': {}",
|
||||
err
|
||||
);
|
||||
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);
|
||||
|
||||
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) {
|
||||
|
||||
@@ -155,7 +155,26 @@ func (c *Control) startResumeWorker(duration time.Duration) {
|
||||
}
|
||||
case <-time.After(duration):
|
||||
wc.Info("Resuming...")
|
||||
return c.resume()
|
||||
|
||||
err := c.resume()
|
||||
if err == nil {
|
||||
n := ¬ifications.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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user