From c42c708db5b43e1837cd6e69bc308be4f4120108 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sun, 24 Jul 2022 20:12:30 -0700 Subject: [PATCH] fix opening and some other stuff --- src/ui/Mods.tsx | 4 ---- src/ui/components/mods/ModTile.tsx | 3 ++- src/utils/gamebanana.ts | 7 ++++++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/Mods.tsx b/src/ui/Mods.tsx index 5397cac..5361774 100644 --- a/src/ui/Mods.tsx +++ b/src/ui/Mods.tsx @@ -69,12 +69,8 @@ export class Mods extends React.Component { const firstLink = dlLinks[0].downloadUrl this.props.downloadHandler.addDownload(firstLink, modPath, async () => { - console.log('Unzipping:', mod.name) const unzipRes = await unzip(modPath, modFolder, false) - console.log(`${unzipRes.new_folder}/modinfo.json`) - console.log(unzipRes) - // Write a modinfo.json file invoke('write_file', { path: `${unzipRes.new_folder}/modinfo.json`, diff --git a/src/ui/components/mods/ModTile.tsx b/src/ui/components/mods/ModTile.tsx index db8c9a8..85d9706 100644 --- a/src/ui/components/mods/ModTile.tsx +++ b/src/ui/components/mods/ModTile.tsx @@ -41,7 +41,8 @@ export class ModTile extends React.Component { onMouseLeave={() => this.setState({ hover: false })} onClick={() => { // Disable downloading installed mods - if (!('id' in mod)) return this.openInExplorer() + if (this.props.path) return this.openInExplorer() + if (!('id' in mod)) return this.props.onClick(mod) }} diff --git a/src/utils/gamebanana.ts b/src/utils/gamebanana.ts index 0cb94e8..ce129b8 100644 --- a/src/utils/gamebanana.ts +++ b/src/utils/gamebanana.ts @@ -169,8 +169,13 @@ export async function getInstalledMods() { return Object.keys(mods).map((path) => { const info = JSON.parse(mods[path]) as ModData | PartialModData + const modPathArr = path.replace(/\\/g, '/').split('/') + + // If there is a file in this path, remove it from the path + if (modPathArr[modPathArr.length - 1].includes('.')) modPathArr.pop() + return { - path, + path: modPathArr.join('/'), info, } })