From 5193485b5c66170330b920d891e3fe1442cc1f3d Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 23 Feb 2022 18:33:59 +0100 Subject: implement ability to disable NS auto-updates Albeit with some caveats, due to the way electron-updater is setup, if you're not on a version of Viper which supports auto-updates the event which runs the NS Updater code will never be run, and hence it'll never auto-update. This was also an issue before, but I only noticed it now. --- src/index.js | 8 +++++++- src/utils.js | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/index.js b/src/index.js index fa2a35f..0e8364f 100644 --- a/src/index.js +++ b/src/index.js @@ -59,7 +59,13 @@ function start() { win.webContents.send("mods", utils.mods.list()); }); - if (utils.settings.autoupdate) {utils.updatevp(false)} + if (utils.settings.autoupdate) { + utils.updatevp(false) + } else { + if (utils.settings.nsupdate) { + utils.update(); + } + } autoUpdater.on("update-downloaded", () => { win.webContents.send("updateavailable") diff --git a/src/utils.js b/src/utils.js index 2449a73..655eee0 100644 --- a/src/utils.js +++ b/src/utils.js @@ -75,7 +75,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 handleNorthstarAutoUpdating() { +function handleNorthstarUpdating() { if (!settings.autoupdate || !fs.existsSync("viper.json") || settings.gamepath.length === 0) { return; } @@ -314,8 +314,11 @@ function updatevp(autoinstall) { autoUpdater.on("error", (info) => {cli.exit(1)}); autoUpdater.on("update-not-available", (info) => { - // only check for N* updates if Viper itself has no updates - handleNorthstarAutoUpdating(); + // only check for NS updates if Viper itself has no updates and + // if NS auto updates is enabled. + if (settings.nsupdate || cli.hasArgs()) { + handleNorthstarUpdating(); + } cli.exit(); }); @@ -767,6 +770,7 @@ module.exports = { getNSVersion, getTF2Version, isGameRunning, + handleNorthstarUpdating, setlang: (lang) => { settings.lang = lang; saveSettings(); -- cgit v1.2.3