'use client' import { useEffect } from 'react' import '@/app/Installs.css' import { invoke } from '@tauri-apps/api/core' import { useGlobal } from '@/providers/GlobalProvider' import { useRouter, useSearchParams } from 'next/navigation' import { platform } from '@tauri-apps/plugin-os' import { faWarning } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { ask } from '@tauri-apps/plugin-dialog' import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' import { openFolder } from '@/lib/util' export default function Installs () { const { versionsList, serverVersionList, showPopup, setShowPopup, setPopupMode, setFadeOut, setSelectedVersionList, setManagingVersion, setSelectedGame, category, setCategory, downloadVersions, downloadProgress, linuxUseWine, linuxWineCommand, versions } = useGlobal() const params = useSearchParams() const router = useRouter() const id = Number(params.get('id') || 0) const game = serverVersionList?.games.find(g => g.id === id) useEffect(() => { if (!showPopup) return setSelectedVersionList([]) }, [setSelectedVersionList, showPopup]) if (!id || !game) return
Invalid game
const needsRevisionUpdate = ( lastRevision: number | undefined, version: string ) => { if (!lastRevision) return false return ( lastRevision > 0 && (versionsList == undefined ? 0 : versionsList[version]) / 1000 <= lastRevision ) } return ({game.name} Installs
{value}
{(() => { const count = Object.keys(versionsList).filter(v => { const info = serverVersionList?.versions.find( vf => vf.id == v ) if (!info) return false if ( platform() == 'linux' && info.wine && !linuxUseWine ) return false return ( info.game === id && info.category == Number(key) ) }).length ?? 0 return `${count} install${count === 1 ? '' : 's'}` })()}
{versionInfo.displayName}
Installed{' '} {new Intl.DateTimeFormat(undefined).format( versionsList[v] )}
Uses wine
Needs revision update!