From 5884b9a8e91ed8b2c5cfea90afa2709697b05afb Mon Sep 17 00:00:00 2001 From: GitExample Date: Thu, 3 Feb 2022 23:03:33 +0100 Subject: detection for new updates of mods --- src/app/browser.js | 9 +++++++++ src/app/main.js | 2 ++ src/lang/en.json | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/app/browser.js b/src/app/browser.js index b387a6a..dda0441 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -95,8 +95,17 @@ function BrowserEl(properties) { } let installstr = lang("gui.browser.install"); + if (normalize(modsdiv.innerText.split("\n")).includes(normalize(properties.title))) { installstr = lang("gui.browser.reinstall"); + + for (let i = 0; i < modsobj.all.length; i++) { + if (normalize(modsobj.all[i].Name) == normalize(properties.title) + && "v" + modsobj.all[i].Version != properties.version) { + + installstr = lang("gui.browser.update"); + } + } } browserEntries.innerHTML += ` diff --git a/src/app/main.js b/src/app/main.js index fa7cea8..08c70c1 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -3,6 +3,7 @@ const path = require("path"); const { ipcRenderer, shell } = require("electron"); const lang = require("../lang"); +var modsobj = {}; let shouldInstallNorthstar = false; // Base settings @@ -180,6 +181,7 @@ ipcRenderer.on("alert", (event, msg) => {alert(msg)}) // Updates the installed mods ipcRenderer.on("mods", (event, mods) => { + modsobj = mods; modcount.innerHTML = `${lang("gui.mods.count")} ${mods.all.length}`; modsdiv.innerHTML = ""; diff --git a/src/lang/en.json b/src/lang/en.json index 47bfacb..59af04b 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -63,10 +63,11 @@ "gui.mods.installing": "Installing mod...", "gui.mods.installedmod": "Installed mod!", - "gui.browser.loading": "Loading mods...", "gui.browser.madeby": "by", + "gui.browser.update": "Update", "gui.browser.install": "Install", "gui.browser.reinstall": "Re-Install", + "gui.browser.loading": "Loading mods...", "gui.update.downloading": "Downloading...", "gui.update.extracting": "Extracting update...", -- cgit v1.2.3