From e8dec1a1b26655280b7d07ed33cc178f6261734a Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Fri, 13 Mar 2026 18:11:58 -0700 Subject: [PATCH] Add types to downloads, will be for modding stuff --- src/app/GlobalProvider.tsx | 4 +++- src/app/game/page.tsx | 7 ++++++- src/app/layout.tsx | 17 +++++++++-------- src/componets/popups/ManageVersion.tsx | 7 ++++++- src/componets/popups/VersionsDownload.tsx | 8 +++++++- src/types/DownloadProgress.ts | 3 ++- 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/app/GlobalProvider.tsx b/src/app/GlobalProvider.tsx index 64f777a..0d6b2e8 100644 --- a/src/app/GlobalProvider.tsx +++ b/src/app/GlobalProvider.tsx @@ -42,7 +42,9 @@ type GlobalCtxType = { } | null viewingInfoFromDownloads: boolean version: string | null - downloadVersions: (list: string[]) => Promise + downloadVersions: ( + list: Array<{ id: string; type: 0 | 1 | 2 }> + ) => Promise category: number setCategory: Dispatch> downloadQueue: string[] diff --git a/src/app/game/page.tsx b/src/app/game/page.tsx index 380628e..f7e02db 100644 --- a/src/app/game/page.tsx +++ b/src/app/game/page.tsx @@ -276,7 +276,12 @@ export default function Installs () { //reinstall setSelectedVersionList([entry]) - downloadVersions([entry]) + downloadVersions([ + { + id: entry, + type: 0 + } + ]) } else { openFolder(entry) } diff --git a/src/app/layout.tsx b/src/app/layout.tsx index d9a02e0..4f2763e 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -361,22 +361,22 @@ export default function RootLayout ({ }, []) const downloadVersions = useCallback( - async (list: string[]): Promise => { + async (list: Array<{ id: string; type: 0 | 1 | 2 }>): Promise => { if (list.length === 0) return setSelectedVersionList([]) const newVersions = list.filter( - version => - !downloadQueue.includes(version) && - !downloadProgress.some(d => d.version === version) + item => + !downloadQueue.includes(item.id) && + !downloadProgress.some(d => d.version === item.id) ) if (newVersions.length === 0) return const newDownloads = newVersions.map( - version => + item => new DownloadProgress( - version, + item.id, 0, 0, false, @@ -393,12 +393,13 @@ export default function RootLayout ({ 0, null, null, - null + null, + item.type ) ) setDownloadProgress(prev => [...prev, ...newDownloads]) - setDownloadQueue(prev => [...prev, ...newVersions]) + setDownloadQueue(prev => [...prev, ...newVersions.map(v => v.id)]) }, [downloadQueue, downloadProgress] ) diff --git a/src/componets/popups/ManageVersion.tsx b/src/componets/popups/ManageVersion.tsx index 24c7079..29034fb 100644 --- a/src/componets/popups/ManageVersion.tsx +++ b/src/componets/popups/ManageVersion.tsx @@ -196,7 +196,12 @@ export default function ManageVersionPopup () { //reinstall setSelectedVersionList([managingVersion]) - downloadVersions([managingVersion]) + downloadVersions([ + { + id: managingVersion, + type: 0 + } + ]) }} title="Click to reinstall this game. This will NOT remove any progress or any save files. This WILL uninstall any modifications to the game's executable files." hidden={viewingInfoFromDownloads} diff --git a/src/componets/popups/VersionsDownload.tsx b/src/componets/popups/VersionsDownload.tsx index 30e4088..9c872aa 100644 --- a/src/componets/popups/VersionsDownload.tsx +++ b/src/componets/popups/VersionsDownload.tsx @@ -15,6 +15,7 @@ export default function VersionsDownloadPopup () { downloadVersions, getGameInfo } = useGlobal() + if (!selectedGame) return <> return ( @@ -78,7 +79,12 @@ export default function VersionsDownloadPopup () { className='button btntheme1 w-fit mt-2 -mb-4' onClick={() => { if (downloadedVersionsConfig) { - downloadVersions(selectedVersionList) + downloadVersions( + selectedVersionList.map(versionId => ({ + id: versionId, + type: 0 + })) + ) setPopupMode(1) } }} diff --git a/src/types/DownloadProgress.ts b/src/types/DownloadProgress.ts index 4da999e..b92e050 100644 --- a/src/types/DownloadProgress.ts +++ b/src/types/DownloadProgress.ts @@ -17,6 +17,7 @@ export class DownloadProgress { public unzipped: number, public url: string | null, public executable: string | null, - public hash: string | null + public hash: string | null, + public type: 0 | 1 | 2 ) {} }