feat: add 'Check for updates' option to tray menu and improve update handling

This commit is contained in:
PandaDEV 2025-01-01 18:26:37 +10:00
parent e29f2fcfa5
commit 6157eb75a1
No known key found for this signature in database
GPG key ID: 13EFF9BAF70EE75C
4 changed files with 41 additions and 15 deletions

View file

@ -23,6 +23,7 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
.build(app)?])
.items(&[&MenuItemBuilder::with_id("show", "Show/Hide").build(app)?])
.items(&[&MenuItemBuilder::with_id("keybind", "Change keybind").build(app)?])
.items(&[&MenuItemBuilder::with_id("check_updates", "Check for updates").build(app)?])
.items(&[&MenuItemBuilder::with_id("quit", "Quit").build(app)?])
.build()?,
)
@ -48,6 +49,13 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
let _ = _app.track_event("tray_keybind_change", None);
window.emit("change_keybind", ()).unwrap();
}
"check_updates" => {
let _ = _app.track_event("tray_check_updates", None);
let app_handle = _app.app_handle().clone();
tauri::async_runtime::spawn(async move {
crate::api::updater::check_for_updates(app_handle, true).await;
});
}
_ => (),
})
.icon(icon)