import { useState } from 'react' import { invoke } from '@tauri-apps/api/core' import { useAppContext } from '@/contexts/useAppContext' import { useAppLogic, useConflictDetection, useDisclaimer } from '@/hooks' import './styles/main.scss' // Layout components import { Header, Sidebar, InitialLoadingScreen, ErrorBoundary, UpdateScreen, AnimatedBackground, } from '@/components/layout' // Dialog components import { ProgressDialog, DlcSelectionDialog, SettingsDialog, ConflictDialog, DisclaimerDialog, UnlockerSelectionDialog, } from '@/components/dialogs' // Game components import { GameList } from '@/components/games' /** * Main application component */ function App() { const [updateComplete, setUpdateComplete] = useState(false) const { showDisclaimer, handleDisclaimerClose } = useDisclaimer() // Get application logic from hook const { filter, setFilter, searchQuery, handleSearchChange, isInitialLoad, scanProgress, filteredGames, handleRefresh, isLoading, error, } = useAppLogic({ autoLoad: updateComplete }) // Get action handlers from context const { games, dlcDialog, handleDlcDialogClose, handleProgressDialogClose, progressDialog, handleGameAction, handleDlcConfirm, handleGameEdit, handleUpdateDlcs, settingsDialog, handleSettingsOpen, handleSettingsClose, handleSmokeAPISettingsOpen, showToast, unlockerSelectionDialog, handleSelectCreamLinux, handleSelectSmokeAPI, closeUnlockerDialog, } = useAppContext() // Conflict detection const { conflicts, showDialog, resolveConflict, closeDialog } = useConflictDetection(games) // Handle conflict resolution const handleConflictResolve = async ( gameId: string, conflictType: 'cream-to-proton' | 'smoke-to-native' ) => { try { // Invoke backend to resolve the conflict await invoke('resolve_platform_conflict', { gameId, conflictType, }) // Remove from UI resolveConflict(gameId, conflictType) showToast('Conflict resolved successfully', 'success') } catch (error) { console.error('Error resolving conflict:', error) showToast('Failed to resolve conflict', 'error') } } // Show update screen first if (!updateComplete) { return setUpdateComplete(true)} /> } // Then show initial loading screen if (isInitialLoad) { return } return (
{/* Animated background */} {/* Header with search */}
{/* Sidebar for filtering */} {/* Show error or game list */} {error ? (

Error Loading Games

{error}

) : ( )}
{/* Progress Dialog */} {/* DLC Selection Dialog */} {/* Settings Dialog */} {/* Conflict Detection Dialog */} {/* Unlocker Selection Dialog */} {/* Disclaimer Dialog - Shows AFTER everything is loaded */}
) } export default App