diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2024-08-13 22:44:24 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2024-08-13 22:44:24 +0200 |
commit | 64107e982faf196537b403eb6319796914d7585e (patch) | |
tree | c4b682004069c2fc8cea0b78843a958c18f5c7ce /src/app/js | |
parent | 56f2cb84412252ae0a90076b861f3b1be32be01d (diff) | |
download | Viper-64107e982faf196537b403eb6319796914d7585e.tar.gz Viper-64107e982faf196537b403eb6319796914d7585e.zip |
chore: rework protocol mod installs to use renderer package list
This is achieved by sending an IPC event to the renderer and waiting for a reply once
Since this is async we return from the function after sending the event and recursively invoke it once the reply arrives
The package data is returned a a JSON String because Electron is unable to copy the Object over IPC
Diffstat (limited to 'src/app/js')
-rw-r--r-- | src/app/js/browser.js | 2 | ||||
-rw-r--r-- | src/app/js/mods.js | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/app/js/browser.js b/src/app/js/browser.js index 3415ebf..153c7b5 100644 --- a/src/app/js/browser.js +++ b/src/app/js/browser.js @@ -477,6 +477,8 @@ browser.mod_el = (properties) => { browserEntries.appendChild(entry); } +browser.packages = () => { return packages; } + let recent_toasts = {}; function add_recent_toast(name, timeout = 3000) { if (recent_toasts[name]) {return} diff --git a/src/app/js/mods.js b/src/app/js/mods.js index f463ddb..b257753 100644 --- a/src/app/js/mods.js +++ b/src/app/js/mods.js @@ -328,4 +328,10 @@ ipcRenderer.on("mods", (event, mods_obj) => { mods.load(mods_obj); }) +ipcRenderer.on("packages", (event) => { + // Its not possible to send over the package object directly, so we serialize it + const packages = JSON.stringify(browser.packages()); + event.sender.send("packages-reply", [packages]); +}) + module.exports = mods; |