From c56a903d559af562638cf1bd3f504a7d78a9e805 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Wed, 7 Jan 2026 18:14:33 -0700 Subject: [PATCH] Moove stuff around to make more sense --- src/app/layout.tsx | 112 ++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 57 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 25db2df..4f58cbf 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -81,20 +81,51 @@ export default function RootLayout ({ useState(false) const [selectedGame, setSelectedGame] = useState(null) - function handleOverlayClick (e: React.MouseEvent) { - if (e.target === e.currentTarget) { - if (viewingInfoFromDownloads) { - setPopupMode(0) - setViewingInfoFromDownloads(false) - setManagingVersion(null) - setSelectedGame(null) - } - setFadeOut(true) - setTimeout(() => setShowPopup(false), 200) - } + const pathname = usePathname() + + function getSpecialVersionsList (game?: number): GameVersion[] { + if (!normalConfig || !serverVersionList) return [] + + return serverVersionList.versions + .filter(v => !downloadedVersionsConfig?.list.includes(v.id)) + .filter(v => { + if (game && v.game != game) return false + if (downloadProgress.length != 0) { + return !downloadProgress.some(d => d.version === v.id) + } + return true + }) + .sort((a, b) => { + if (b.game !== a.game) return a.game - b.game + return 0 + }) } - const pathname = usePathname() + function getVersionInfo (id: string | undefined): GameVersion | undefined { + if (!id) return undefined + return serverVersionList?.versions.find(v => v.id === id) + } + + function getGameInfo (game: number | undefined): Game | undefined { + if (!game) return undefined + return serverVersionList?.games.find(g => g.id === game) + } + + function getListOfGames (): Game[] { + if (!downloadedVersionsConfig?.list) return [] + + const gamesMap = new Map() + + downloadedVersionsConfig.list.forEach(i => { + const version = getVersionInfo(i) + if (!version) return + const game = getGameInfo(version.game) + if (!game) return + gamesMap.set(game.id, game) + }) + + return Array.from(gamesMap.values()) + } useEffect(() => { let unlistenProgress: (() => void) | null = null @@ -197,50 +228,6 @@ export default function RootLayout ({ return () => document.removeEventListener('contextmenu', handler) }, []) - function getSpecialVersionsList (game?: number): GameVersion[] { - if (!normalConfig || !serverVersionList) return [] - - return serverVersionList.versions - .filter(v => !downloadedVersionsConfig?.list.includes(v.id)) - .filter(v => { - if (game && v.game != game) return false - if (downloadProgress.length != 0) { - return !downloadProgress.some(d => d.version === v.id) - } - return true - }) - .sort((a, b) => { - if (b.game !== a.game) return a.game - b.game - return 0 - }) - } - - function getVersionInfo (id: string | undefined): GameVersion | undefined { - if (!id) return undefined - return serverVersionList?.versions.find(v => v.id === id) - } - - function getGameInfo (game: number | undefined): Game | undefined { - if (!game) return undefined - return serverVersionList?.games.find(g => g.id === game) - } - - function getListOfGames (): Game[] { - if (!downloadedVersionsConfig?.list) return [] - - const gamesMap = new Map() - - downloadedVersionsConfig.list.forEach(i => { - const version = getVersionInfo(i) - if (!version) return - const game = getGameInfo(version.game) - if (!game) return - gamesMap.set(game.id, game) - }) - - return Array.from(gamesMap.values()) - } - async function downloadVersions (): Promise { const list = selectedVersionList setSelectedVersionList([]) @@ -447,7 +434,18 @@ export default function RootLayout ({ {showPopup && (
) => { + if (e.target === e.currentTarget) { + if (viewingInfoFromDownloads) { + setPopupMode(0) + setViewingInfoFromDownloads(false) + setManagingVersion(null) + setSelectedGame(null) + } + setFadeOut(true) + setTimeout(() => setShowPopup(false), 200) + } + }} >