mirror of
https://github.com/safing/portmaster
synced 2025-04-25 13:29:10 +00:00
[dekstop] Add subscription to the shutdown event
This commit is contained in:
parent
0b52c5347a
commit
3131fb28cc
1 changed files with 27 additions and 0 deletions
|
@ -260,6 +260,22 @@ pub async fn tray_handler(cli: PortAPI, app: tauri::AppHandle) {
|
|||
}
|
||||
};
|
||||
|
||||
let mut portmaster_shutdown_event_subscription = match cli
|
||||
.request(Request::Subscribe(
|
||||
"query runtime:modules/core/event/shutdown".to_string(),
|
||||
))
|
||||
.await
|
||||
{
|
||||
Ok(rx) => rx,
|
||||
Err(err) => {
|
||||
error!(
|
||||
"cancel try_handler: failed to subscribe to 'runtime:modules/core/event/shutdown': {}",
|
||||
err
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
_ = icon.set_icon(Some(Image::from_bytes(BLUE_ICON).unwrap()));
|
||||
|
||||
let mut subsystems: HashMap<String, Subsystem> = HashMap::new();
|
||||
|
@ -358,6 +374,17 @@ pub async fn tray_handler(cli: PortAPI, app: tauri::AppHandle) {
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
msg = portmaster_shutdown_event_subscription.recv() => {
|
||||
let msg = match msg {
|
||||
Some(m) => m,
|
||||
None => { break }
|
||||
};
|
||||
debug!("Shutdown request received: {:?}", msg);
|
||||
match msg {
|
||||
Response::Ok(_, _) | Response::New(_, _) | Response::Update(_, _) => app.exit(0),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue