1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-24 07:30:19 +01:00
upscayl/electron/commands/auto-update.ts

31 lines
980 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
);
} else {
logit("🚫 Update Installation Cancelled");
}
2023-09-11 04:28:33 +02:00
};
export default autoUpdate;