diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2024-08-13 23:02:34 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2024-08-13 23:02:34 +0200 |
commit | 05d9c0acd4c87d34ed31edc6683e2932058a30dd (patch) | |
tree | a4ff88b1b2474f4a52085cac42c73cce61ee9f14 /src/app/js | |
parent | 64107e982faf196537b403eb6319796914d7585e (diff) | |
download | Viper-05d9c0acd4c87d34ed31edc6683e2932058a30dd.tar.gz Viper-05d9c0acd4c87d34ed31edc6683e2932058a30dd.zip |
chore: use existing mod installation logic for r2mm protocol
Diffstat (limited to 'src/app/js')
-rw-r--r-- | src/app/js/browser.js | 5 | ||||
-rw-r--r-- | src/app/js/mods.js | 35 |
2 files changed, 35 insertions, 5 deletions
diff --git a/src/app/js/browser.js b/src/app/js/browser.js index 153c7b5..b2e0493 100644 --- a/src/app/js/browser.js +++ b/src/app/js/browser.js @@ -477,7 +477,10 @@ browser.mod_el = (properties) => { browserEntries.appendChild(entry); } -browser.packages = () => { return packages; } +browser.packages = async () => { + await browser.loadfront(); + return packages; +} let recent_toasts = {}; function add_recent_toast(name, timeout = 3000) { diff --git a/src/app/js/mods.js b/src/app/js/mods.js index b257753..349f5b9 100644 --- a/src/app/js/mods.js +++ b/src/app/js/mods.js @@ -328,10 +328,37 @@ 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]); +ipcRenderer.on("protocol-install-mod", async (event, data) => { + const domain = data[0]; + const author = data[1]; + const package_name = data[2]; + const version = data[3]; + + const packages = await browser.packages(); + + const package = packages.find((package) => { return package.owner == author && package.name == package_name; }) + if (!package) { + console.error("Couldn't find package") + return; + } + + const package_obj = package.versions.find((package_version) => { return package_version.version_number == version; }) + if (!package_obj) { + console.error("Couldn't find package_version") + return; + } + + console.log(package_obj); + + mods.install_from_url( + package_obj.download_url, + package_obj.dependencies, + false, + + author, + package_name, + version + ); }) module.exports = mods; |