diff --git a/main.js b/main.js index f92d5b6..95ac871 100644 --- a/main.js +++ b/main.js @@ -208,9 +208,13 @@ function saveBepinexVersion(version) { } ipcMain.handle("load-bepinex-version", () => { + return loadBepinexVersion(); +}); + +function loadBepinexVersion() { bepinexVersion = bepinexStore.get("bepinex-version"); return bepinexVersion; -}); +} function saveBepinexBackupVersion(version) { bepinexBackupVersion = version; @@ -377,8 +381,6 @@ async function installBepinex() { saveBepinexVersion(bepinexBackupVersion); saveBepinexBackupVersion(undefined); } else { - mainWindow.webContents.send("showToast", "Installing Bepinex from Github"); - const GITHUB_URL = "https://api.github.com/repos/bepinex/bepinex/releases/latest"; const res = await fetch(GITHUB_URL, { @@ -397,6 +399,14 @@ async function installBepinex() { const release = await res.json(); + if (loadBepinexVersion() == release.tag_name) { + mainWindow.webContents.send("showToast", "No new BepInEx update."); + return; + } + mainWindow.webContents.send("showToast", "Installing Bepinex from Github"); + + await uninstallBepinex(); + let asset; if (process.platform === "win32") { asset = release.assets.find((a) => a.name.endsWith(".zip") && a.name.toLowerCase().includes("win_x64")); diff --git a/renderer/index.html b/renderer/index.html index a7ffa63..ac33454 100644 --- a/renderer/index.html +++ b/renderer/index.html @@ -281,7 +281,7 @@


- + diff --git a/renderer/renderer.js b/renderer/renderer.js index b556204..0935611 100644 --- a/renderer/renderer.js +++ b/renderer/renderer.js @@ -589,6 +589,7 @@ async function deleteBepinexBackup() { async function setBepinexVersion() { const bepinexVersionText = document.getElementById("bepinex-version-text"); + const bepinexInstallButton = document.getElementById("install-bepinex-button"); if (bepinexVersionText == undefined) { return; } @@ -601,8 +602,10 @@ async function setBepinexVersion() { } else { bepinexVersionText.innerText = `BepInEx ${bepinexBackupVersion} is backed up`; } + bepinexInstallButton.innerText = "Install"; } else { bepinexVersionText.innerText = `BepInEx ${bepinexVersion} is installed`; + bepinexInstallButton.innerText = "Update"; } }