mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-01-29 23:02:50 -05:00
index & hook #89
This commit is contained in:
68
src/App.tsx
68
src/App.tsx
@@ -1,13 +1,27 @@
|
||||
import { useState } from 'react'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import { useAppContext } from '@/contexts/useAppContext'
|
||||
import { useAppLogic } from '@/hooks'
|
||||
import { useAppLogic, useConflictDetection } from '@/hooks'
|
||||
import './styles/main.scss'
|
||||
|
||||
// Layout components
|
||||
import { Header, Sidebar, InitialLoadingScreen, ErrorBoundary, UpdateScreen, AnimatedBackground } from '@/components/layout'
|
||||
import {
|
||||
Header,
|
||||
Sidebar,
|
||||
InitialLoadingScreen,
|
||||
ErrorBoundary,
|
||||
UpdateScreen,
|
||||
AnimatedBackground,
|
||||
} from '@/components/layout'
|
||||
|
||||
// Dialog components
|
||||
import { ProgressDialog, DlcSelectionDialog, SettingsDialog } from '@/components/dialogs'
|
||||
import {
|
||||
ProgressDialog,
|
||||
DlcSelectionDialog,
|
||||
SettingsDialog,
|
||||
ConflictDialog,
|
||||
ReminderDialog,
|
||||
} from '@/components/dialogs'
|
||||
|
||||
// Game components
|
||||
import { GameList } from '@/components/games'
|
||||
@@ -17,6 +31,7 @@ import { GameList } from '@/components/games'
|
||||
*/
|
||||
function App() {
|
||||
const [updateComplete, setUpdateComplete] = useState(false)
|
||||
|
||||
// Get application logic from hook
|
||||
const {
|
||||
filter,
|
||||
@@ -33,6 +48,7 @@ function App() {
|
||||
|
||||
// Get action handlers from context
|
||||
const {
|
||||
games,
|
||||
dlcDialog,
|
||||
handleDlcDialogClose,
|
||||
handleProgressDialogClose,
|
||||
@@ -45,8 +61,30 @@ function App() {
|
||||
handleSettingsOpen,
|
||||
handleSettingsClose,
|
||||
handleSmokeAPISettingsOpen,
|
||||
showToast,
|
||||
} = useAppContext()
|
||||
|
||||
// Conflict detection
|
||||
const { currentConflict, showReminder, resolveConflict, closeReminder } =
|
||||
useConflictDetection(games)
|
||||
|
||||
// Handle conflict resolution
|
||||
const handleConflictResolve = async () => {
|
||||
const resolution = resolveConflict()
|
||||
if (!resolution) return
|
||||
|
||||
// Always remove files - use the special conflict resolution command
|
||||
try {
|
||||
await invoke('resolve_platform_conflict', {
|
||||
gameId: resolution.gameId,
|
||||
conflictType: resolution.conflictType,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error resolving conflict:', error)
|
||||
showToast(`Failed to resolve conflict: ${error}`, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
// Show update screen first
|
||||
if (!updateComplete) {
|
||||
return <UpdateScreen onComplete={() => setUpdateComplete(true)} />
|
||||
@@ -73,7 +111,11 @@ function App() {
|
||||
|
||||
<div className="main-content">
|
||||
{/* Sidebar for filtering */}
|
||||
<Sidebar setFilter={setFilter} currentFilter={filter} onSettingsClick={handleSettingsOpen} />
|
||||
<Sidebar
|
||||
setFilter={setFilter}
|
||||
currentFilter={filter}
|
||||
onSettingsClick={handleSettingsOpen}
|
||||
/>
|
||||
|
||||
{/* Show error or game list */}
|
||||
{error ? (
|
||||
@@ -123,10 +165,20 @@ function App() {
|
||||
/>
|
||||
|
||||
{/* Settings Dialog */}
|
||||
<SettingsDialog
|
||||
visible ={settingsDialog.visible}
|
||||
onClose={handleSettingsClose}
|
||||
/>
|
||||
<SettingsDialog visible={settingsDialog.visible} onClose={handleSettingsClose} />
|
||||
|
||||
{/* Conflict Detection Dialog */}
|
||||
{currentConflict && (
|
||||
<ConflictDialog
|
||||
visible={true}
|
||||
gameTitle={currentConflict.gameTitle}
|
||||
conflictType={currentConflict.type}
|
||||
onConfirm={handleConflictResolve}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Steam Launch Options Reminder */}
|
||||
<ReminderDialog visible={showReminder} onClose={closeReminder} />
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user