diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app/settings.js | 5 | ||||
-rw-r--r-- | src/index.js | 10 | ||||
-rw-r--r-- | src/utils.js | 9 |
3 files changed, 20 insertions, 4 deletions
diff --git a/src/app/settings.js b/src/app/settings.js index 4921e07..902e57b 100644 --- a/src/app/settings.js +++ b/src/app/settings.js @@ -96,6 +96,11 @@ var Settings = { } } } + + ipcRenderer.send("can-autoupdate"); + ipcRenderer.on("cant-autoupdate", () => { + document.querySelector(".option[name=autoupdate]").style.display = "none"; + }) } } diff --git a/src/index.js b/src/index.js index 0e8364f..265e13d 100644 --- a/src/index.js +++ b/src/index.js @@ -55,6 +55,12 @@ function start() { ipcMain.on("savesettings", (event, obj) => {utils.saveSettings(obj)}) + ipcMain.on("can-autoupdate", (event) => { + if (! require("electron-updater").autoUpdater.isUpdaterActive()) { + win.webContents.send("cant-autoupdate") + } + }) + win.webContents.on("dom-ready", () => { win.webContents.send("mods", utils.mods.list()); }); @@ -62,9 +68,7 @@ function start() { if (utils.settings.autoupdate) { utils.updatevp(false) } else { - if (utils.settings.nsupdate) { - utils.update(); - } + utils.handleNorthstarUpdating(); } autoUpdater.on("update-downloaded", () => { diff --git a/src/utils.js b/src/utils.js index 655eee0..6069a46 100644 --- a/src/utils.js +++ b/src/utils.js @@ -76,7 +76,7 @@ async function isGameRunning() { // It uses isGameRunning() to ensure it doesn't run while the game is // running, as that may have all kinds of issues. function handleNorthstarUpdating() { - if (!settings.autoupdate || !fs.existsSync("viper.json") || settings.gamepath.length === 0) { + if (! settings.nsupdate || ! fs.existsSync("viper.json") || settings.gamepath.length === 0) { return; } @@ -306,6 +306,13 @@ async function update() { function updatevp(autoinstall) { const { autoUpdater } = require("electron-updater"); + if (! autoUpdater.isUpdaterActive()) { + if (settings.nsupdate) { + handleNorthstarUpdating(); + } + return cli.exit(); + } + if (autoinstall) { autoUpdater.on("update-downloaded", (info) => { autoUpdater.quitAndInstall(); |