From a12c73e95f7de4167d4e20f77d5e942f1e12d179 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 23 Nov 2022 00:49:58 +0100 Subject: actually fix duplicate mods If a mod has multiple mod folders inside it, however all with the same name, they'll be merged together, this now fixes that, by adding "(dupe)" to the end of it, along with displaying an error, however it will install successfully. This also happens to add some duplicate toast protection, however this should be reworked, but I am not bothered to deal with it right now, and I instead will be putting this on future me. --- src/app/browser.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/app/browser.js') diff --git a/src/app/browser.js b/src/app/browser.js index db68d31..995a276 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -373,6 +373,17 @@ function BrowserEl(properties) { browserEntries.appendChild(entry); } +let recent_toasts = {}; +function add_recent_toast(name, timeout = 3000) { + if (recent_toasts[name]) {return} + + recent_toasts[name] = true; + + setTimeout(() => { + delete recent_toasts[name]; + }, timeout) +} + ipcRenderer.on("removed-mod", (event, mod) => { setButtons(true); Browser.setbutton(mod.name, lang("gui.browser.install")); @@ -382,6 +393,9 @@ ipcRenderer.on("removed-mod", (event, mod) => { }) ipcRenderer.on("failed-mod", (event, modname) => { + if (recent_toasts["failed" + modname]) {return} + add_recent_toast("failed" + modname); + setButtons(true); new Toast({ timeout: 10000, @@ -391,6 +405,19 @@ ipcRenderer.on("failed-mod", (event, modname) => { }) }) +ipcRenderer.on("duped-mod", (event, modname) => { + if (recent_toasts["duped" + modname]) {return} + add_recent_toast("duped" + modname); + + setButtons(true); + new Toast({ + timeout: 10000, + scheme: "warning", + title: lang("gui.toast.title.duped"), + description: modname + " " + lang("gui.toast.desc.duped") + }) +}) + ipcRenderer.on("no-internet", (event, modname) => { setButtons(true); new Toast({ @@ -402,6 +429,9 @@ ipcRenderer.on("no-internet", (event, modname) => { }) ipcRenderer.on("installed-mod", (event, mod) => { + if (recent_toasts["installed" + mod.name]) {return} + add_recent_toast("installed" + mod.name); + setButtons(true); Browser.setbutton(mod.name, lang("gui.browser.reinstall")); -- cgit v1.2.3