2023-10-27 16:30:59 +02:00
|
|
|
import { MessageBoxOptions, dialog, shell } from "electron";
|
|
|
|
import { UpdateDownloadedEvent, autoUpdater } from "electron-updater";
|
2023-09-11 04:28:33 +02:00
|
|
|
import logit from "../utils/logit";
|
|
|
|
|
2023-10-27 16:30:59 +02:00
|
|
|
const autoUpdate = (event: UpdateDownloadedEvent) => {
|
2023-09-11 04:28:33 +02:00
|
|
|
autoUpdater.autoInstallOnAppQuit = false;
|
|
|
|
const dialogOpts: MessageBoxOptions = {
|
|
|
|
type: "info",
|
2023-10-27 16:30:59 +02:00
|
|
|
buttons: ["Install update", "No Thanks", "Check Release Notes"],
|
2023-09-11 04:28:33 +02:00
|
|
|
title: "New Upscayl Update",
|
|
|
|
message: event.releaseName as string,
|
|
|
|
detail:
|
|
|
|
"A new version has been downloaded. Restart the application to apply the updates.",
|
|
|
|
};
|
2023-12-04 15:20:42 +01:00
|
|
|
|
|
|
|
const dialogResponse = dialog.showMessageBoxSync(dialogOpts);
|
|
|
|
|
2023-09-11 04:28:33 +02:00
|
|
|
logit("✅ Update Downloaded");
|
2023-12-04 15:20:42 +01:00
|
|
|
if (dialogResponse === 0) {
|
|
|
|
autoUpdater.quitAndInstall();
|
|
|
|
} else if (dialogResponse === 2) {
|
|
|
|
shell.openExternal(
|
|
|
|
"https://github.com/upscayl/upscayl/releases/tag/v" + event.version
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
logit("🚫 Update Installation Cancelled");
|
|
|
|
}
|
2023-09-11 04:28:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default autoUpdate;
|