feat: replace legacy Python CLI with GUI app

This commit is contained in:
Tickbase
2025-05-19 03:41:04 +02:00
parent e55f91a66d
commit 1e2cb52f6f
22 changed files with 118 additions and 222 deletions

View File

@@ -25,7 +25,7 @@ export function useDlcManager() {
const [isFetchingDlcs, setIsFetchingDlcs] = useState(false)
const dlcFetchController = useRef<AbortController | null>(null)
const activeDlcFetchId = useRef<string | null>(null)
const [forceReload, setForceReload] = useState(false) // Add this state to force reloads
const [forceReload, setForceReload] = useState(false)
// DLC selection dialog state
const [dlcDialog, setDlcDialog] = useState<DlcDialogState>({
@@ -156,7 +156,7 @@ export function useDlcManager() {
}
}
// MODIFIED: Handle game edit (show DLC management dialog) with proper reloading
// Handle game edit (show DLC management dialog) with proper reloading
const handleGameEdit = async (gameId: string, games: Game[]) => {
const game = games.find((g) => g.id === gameId)
if (!game || !game.cream_installed) return
@@ -173,17 +173,17 @@ export function useDlcManager() {
visible: true,
gameId,
gameTitle: game.title,
dlcs: [], // Always start with empty DLCs to force a fresh load
dlcs: [],
enabledDlcs: [],
isLoading: true,
isEditMode: true, // This is an edit operation
isEditMode: true,
progress: 0,
progressMessage: 'Reading DLC configuration...',
timeLeft: '',
error: null,
})
// MODIFIED: Always get a fresh copy from the config file
// Always get a fresh copy from the config file
console.log('Loading DLC configuration from disk...')
try {
const allDlcs = await invoke<DlcInfo[]>('get_all_dlcs_command', {
@@ -197,7 +197,7 @@ export function useDlcManager() {
// Log the fresh DLC config
console.log('Loaded existing DLC configuration:', allDlcs)
// IMPORTANT: Create a completely new array to avoid reference issues
// Create a completely new array to avoid reference issues
const freshDlcs = allDlcs.map((dlc) => ({ ...dlc }))
setDlcDialog((prev) => ({
@@ -256,7 +256,7 @@ export function useDlcManager() {
}
}
// MODIFIED: Handle DLC selection dialog close
// Handle DLC selection dialog close
const handleDlcDialogClose = () => {
// Cancel any in-progress DLC fetching
if (isFetchingDlcs && activeDlcFetchId.current) {

View File

@@ -150,7 +150,7 @@ export function useGameActions() {
try {
if (isEditMode) {
// MODIFIED: Create a deep copy to ensure we don't have reference issues
// Create a deep copy to ensure we don't have reference issues
const dlcsCopy = selectedDlcs.map((dlc) => ({ ...dlc }))
// Show progress dialog for editing
@@ -201,7 +201,7 @@ export function useGameActions() {
selectedDlcs,
})
// Note: The progress dialog will be updated through the installation-progress event listener
// The progress dialog will be updated through the installation-progress event listener
}
} catch (error) {
console.error('Error processing DLC selection:', error)

View File

@@ -0,0 +1,43 @@
import { useEffect } from 'react'
import { check } from '@tauri-apps/plugin-updater'
import { useToasts } from '@/hooks'
/**
* Hook that silently checks for updates and shows a toast notification if an update is available
*/
export function useUpdateChecker() {
const { success, error } = useToasts()
useEffect(() => {
// Check for updates on component mount
const checkForUpdates = async () => {
try {
// Check for updates
const update = await check()
// If update is available, show a toast notification
if (update) {
console.log(`Update available: ${update.version}`)
success(`Update v${update.version} available! Check GitHub for details.`, {
duration: 8000 // Show for 8 seconds
})
}
} catch (err) {
// Log error but don't show to user
console.error('Update check failed:', err)
}
}
// Small delay to avoid interfering with app startup
const timer = setTimeout(() => {
checkForUpdates()
}, 3000)
return () => clearTimeout(timer)
}, [success, error])
// This hook doesn't return anything
return null
}
export default useUpdateChecker