Merge branch 'main' into issue/settings

This commit is contained in:
PandaDEV 2025-01-10 22:20:44 +10:00 committed by GitHub
commit dde27b37a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 50 additions and 33 deletions

View file

@ -2,7 +2,7 @@ use tauri::{ async_runtime, AppHandle };
use tauri_plugin_dialog::{ DialogExt, MessageDialogButtons, MessageDialogKind };
use tauri_plugin_updater::UpdaterExt;
pub async fn check_for_updates(app: AppHandle) {
pub async fn check_for_updates(app: AppHandle, prompted: bool) {
println!("Checking for updates...");
let updater = app.updater().unwrap();
@ -18,6 +18,10 @@ pub async fn check_for_updates(app: AppHandle) {
"Would you like to install it now?",
]);
let window = app.get_webview_window("main").unwrap();
window.show().unwrap();
window.set_focus().unwrap();
app.dialog()
.message(msg)
.title("Qopy Update Available")
@ -69,9 +73,22 @@ pub async fn check_for_updates(app: AppHandle) {
});
});
}
Ok(None) => println!("No updates available."),
Ok(None) => {
println!("No updates available.");
}
Err(e) => {
println!("Failed to check for updates: {:?}", e);
if prompted {
let window = app.get_webview_window("main").unwrap();
window.show().unwrap();
window.set_focus().unwrap();
app.dialog()
.message("No updates available.")
.title("Qopy Update Check")
.show(|_| {});
}
println!("No updates available. {}", e.to_string());
}
}
}

View file

@ -99,7 +99,7 @@ fn main() {
let _ = app.track_event("app_started", None);
tauri::async_runtime::spawn(async move {
api::updater::check_for_updates(app_handle).await;
api::updater::check_for_updates(app_handle, false).await;
});
Ok(())