diff options
author | 0neGal <mail@0negal.com> | 2022-11-23 00:49:58 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2022-11-23 00:49:58 +0100 |
commit | a12c73e95f7de4167d4e20f77d5e942f1e12d179 (patch) | |
tree | f00e9b4b70617506c911840d258dbdfc7b286851 /src/app/browser.js | |
parent | acce3855ab1f99d5e1245696df0123240f7b9034 (diff) | |
download | Viper-a12c73e95f7de4167d4e20f77d5e942f1e12d179.tar.gz Viper-a12c73e95f7de4167d4e20f77d5e942f1e12d179.zip |
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.
Diffstat (limited to 'src/app/browser.js')
-rw-r--r-- | src/app/browser.js | 30 |
1 files changed, 30 insertions, 0 deletions
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")); |