mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 13:14:04 +02:00
fix: new updater method changes
This commit is contained in:
parent
f1813c8886
commit
b6c962d3f3
1 changed files with 21 additions and 9 deletions
|
@ -1,8 +1,7 @@
|
||||||
use tauri::{AppHandle, async_runtime};
|
use tauri::{AppHandle, async_runtime};
|
||||||
use tauri_plugin_dialog::{DialogExt, MessageDialogKind};
|
use tauri_plugin_dialog::{DialogExt, MessageDialogKind, MessageDialogButtons};
|
||||||
use tauri_plugin_updater::UpdaterExt;
|
use tauri_plugin_updater::UpdaterExt;
|
||||||
|
|
||||||
|
|
||||||
pub async fn check_for_updates(app: AppHandle) {
|
pub async fn check_for_updates(app: AppHandle) {
|
||||||
println!("Checking for updates...");
|
println!("Checking for updates...");
|
||||||
|
|
||||||
|
@ -22,18 +21,31 @@ pub async fn check_for_updates(app: AppHandle) {
|
||||||
app.dialog()
|
app.dialog()
|
||||||
.message(msg)
|
.message(msg)
|
||||||
.title("Update Available")
|
.title("Update Available")
|
||||||
.ok_button_label("Install")
|
.buttons(MessageDialogButtons::OkCancelCustom(String::from("Install"), String::from("Cancel")))
|
||||||
.cancel_button_label("Cancel")
|
|
||||||
.show(move |response| {
|
.show(move |response| {
|
||||||
if !response {
|
if !response {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
async_runtime::spawn(async move {
|
async_runtime::spawn(async move {
|
||||||
if let Err(e) = update.download_and_install(|_, _| {}, || {}).await {
|
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);
|
println!("Error installing new update: {:?}", e);
|
||||||
app.dialog().message(
|
app.dialog()
|
||||||
"Failed to install new update. The new update can be downloaded from Github"
|
.message("Failed to install new update. The new update can be downloaded from Github")
|
||||||
).kind(MessageDialogKind::Error).show(|_| {});
|
.kind(MessageDialogKind::Error)
|
||||||
|
.show(|_| {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue