Skip to content

Commit

Permalink
chore: update electron-updater
Browse files Browse the repository at this point in the history
  • Loading branch information
sircharlo committed Oct 10, 2023
1 parent bb4abb1 commit fe93a48
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 418 deletions.
28 changes: 16 additions & 12 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
const {
app,
BrowserWindow,
ipcMain
} = require("electron"), {
autoUpdater
} = require("electron-updater"),
const { app, BrowserWindow, ipcMain } = require("electron"),
{ autoUpdater } = require("electron-updater"),
os = require("os"),
remote = require("@electron/remote/main");
var win = {};
Expand All @@ -13,13 +8,13 @@ function createUpdateWindow() {
win = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
contextIsolation: false
contextIsolation: false,
},
minWidth: 1366,
minHeight: 768,
fullscreen: true,
// alwaysOnTop: true,
title: "JW Launcher"
title: "JW Launcher",
});
const ses = win.webContents.session;
ses.clearCache();
Expand All @@ -28,7 +23,9 @@ function createUpdateWindow() {
win.setMenuBarVisibility(false);
win.loadFile("index.html");
win.maximize();
win.on("show", () => { win.focus(); });
win.on("show", () => {
win.focus();
});
win.show();
}
const gotTheLock = app.requestSingleInstanceLock();
Expand All @@ -43,7 +40,11 @@ if (!gotTheLock) {
});
ipcMain.on("autoUpdate", () => {
win.webContents.send("hideThenShow", ["InternetCheck", "UpdateCheck"]);
autoUpdater.checkForUpdates();
autoUpdater.checkForUpdates().then((result) => {
if (!result) {
win.webContents.send("goAhead");
}
});
});
autoUpdater.on("error", () => {
win.webContents.send("goAhead");
Expand All @@ -64,7 +65,10 @@ if (!gotTheLock) {
win.webContents.send("updateDownloadProgress", [prog.percent]);
});
autoUpdater.on("update-downloaded", () => {
win.webContents.send("hideThenShow", ["UpdateAvailable", "UpdateDownloaded"]);
win.webContents.send("hideThenShow", [
"UpdateAvailable",
"UpdateDownloaded",
]);
setImmediate(() => {
autoUpdater.quitAndInstall();
});
Expand Down
Loading

0 comments on commit fe93a48

Please sign in to comment.