diff --git a/src-tauri/src/api/updater.rs b/src-tauri/src/api/updater.rs index 6c474c2..b8ef00e 100644 --- a/src-tauri/src/api/updater.rs +++ b/src-tauri/src/api/updater.rs @@ -1,8 +1,7 @@ use tauri::{AppHandle, async_runtime}; -use tauri_plugin_dialog::{DialogExt, MessageDialogKind}; +use tauri_plugin_dialog::{DialogExt, MessageDialogKind, MessageDialogButtons}; use tauri_plugin_updater::UpdaterExt; - pub async fn check_for_updates(app: AppHandle) { println!("Checking for updates..."); @@ -22,18 +21,31 @@ pub async fn check_for_updates(app: AppHandle) { app.dialog() .message(msg) .title("Update Available") - .ok_button_label("Install") - .cancel_button_label("Cancel") + .buttons(MessageDialogButtons::OkCancelCustom(String::from("Install"), String::from("Cancel"))) .show(move |response| { if !response { return; } async_runtime::spawn(async move { - if let Err(e) = update.download_and_install(|_, _| {}, || {}).await { - println!("Error installing new update: {:?}", e); - app.dialog().message( - "Failed to install new update. The new update can be downloaded from Github" - ).kind(MessageDialogKind::Error).show(|_| {}); + match update.download_and_install(|_, _| {}, || {}).await { + Ok(_) => { + app.dialog() + .message("Update installed successfully. The application needs to restart to apply the changes.") + .title("Update Installed") + .buttons(MessageDialogButtons::OkCancelCustom(String::from("Restart"), String::from("Cancel"))) + .show(move |response| { + if response { + app.restart(); + } + }); + } + Err(e) => { + println!("Error installing new update: {:?}", e); + app.dialog() + .message("Failed to install new update. The new update can be downloaded from Github") + .kind(MessageDialogKind::Error) + .show(|_| {}); + } } }); });