1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-03 19:47:26 +01:00
upscayl/electron/commands/auto-update.ts

32 lines
1023 B
TypeScript
Raw Normal View History

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.",
};
const dialogResponse = dialog.showMessageBoxSync(dialogOpts);
2023-09-11 04:28:33 +02:00
logit("✅ Update Downloaded");
if (dialogResponse === 0) {
autoUpdater.quitAndInstall();
} else if (dialogResponse === 2) {
shell.openExternal(
"https://github.com/upscayl/upscayl/releases/tag/v" + event.version
);
dialog.showMessageBoxSync(dialogOpts);
} else {
logit("🚫 Update Installation Cancelled");
}
2023-09-11 04:28:33 +02:00
};
export default autoUpdate;