This commit is contained in:
Tickbase
2025-05-18 02:57:09 +02:00
parent e29f44bbd5
commit 28a86771fa

View File

@@ -381,15 +381,21 @@ function App() {
setProgressDialog((prev) => ({ ...prev, visible: false }))
// Only refresh if we need to (instructions didn't trigger update)
if (progressDialog.showInstructions === false && !refreshInProgress.current) {
refreshInProgress.current = true
if (
progressDialog.showInstructions === false &&
!progressDialog.title.includes("DLC") &&
!progressDialog.title.includes("Updating") &&
!progressDialog.title.includes("Update") &&
!refreshInProgress.current
) {
refreshInProgress.current = true;
setTimeout(() => {
loadGames().then(() => {
refreshInProgress.current = false
})
}, 100)
refreshInProgress.current = false;
});
}, 100);
}
}
};
// Function to fetch DLCs for a game with streaming updates
const streamGameDlcs = async (gameId: string): Promise<void> => {
@@ -672,22 +678,20 @@ function App() {
// Handle DLC selection confirmation
const handleDlcConfirm = async (selectedDlcs: DlcInfo[]) => {
// The dialog has already started its exit animation
// Just make sure it's marked as invisible
setDlcDialog((prev) => ({ ...prev, visible: false }))
const gameId = dlcDialog.gameId
const game = games.find((g) => g.id === gameId)
if (!game) return
setDlcDialog((prev) => ({ ...prev, visible: false }));
const gameId = dlcDialog.gameId;
const game = games.find((g) => g.id === gameId);
if (!game) return;
// Update local state to show installation in progress
setGames((prevGames) =>
prevGames.map((g) => (g.id === gameId ? { ...g, installing: true } : g))
)
);
try {
if (dlcDialog.isEditMode) {
// If in edit mode, we're updating existing cream_api.ini
// Show progress dialog for editing
setProgressDialog({
visible: true,
title: `Updating DLCs for ${game.title}`,
@@ -695,35 +699,36 @@ function App() {
progress: 30,
showInstructions: false,
instructions: undefined,
})
});
// Call the backend to update the DLC configuration
await invoke('update_dlc_configuration_command', {
gamePath: game.path,
dlcs: selectedDlcs,
})
});
// Update progress dialog for completion
setProgressDialog((prev) => ({
...prev,
title: `Update Complete: ${game.title}`,
message: 'DLC configuration updated successfully!',
progress: 100,
}))
// The ProgressDialog component will now handle the exit animation
// when progress reaches 100% after a delay
}));
// But we still need to reset installing state with a delay
// Most importantly: directly update the local state instead of waiting for a full scan
// This is what prevents the need for a full scan
setTimeout(() => {
// Reset installing state
// Reset installing state and update the game in the local state
setGames((prevGames) =>
prevGames.map((g) => (g.id === gameId ? { ...g, installing: false } : g))
)
}, 2000)
prevGames.map((g) => (g.id === gameId ? {
...g,
installing: false,
// No other properties should need updating for a DLC config change
} : g))
);
}, 2000);
} else {
// We're doing a fresh install with selected DLCs
// Show progress dialog for installation right away
// We're doing a fresh install with selected DLCs - original code unchanged
setProgressDialog({
visible: true,
title: `Installing CreamLinux for ${game.title}`,
@@ -731,38 +736,32 @@ function App() {
progress: 0,
showInstructions: false,
instructions: undefined,
})
// Invoke the installation with the selected DLCs
});
await invoke('install_cream_with_dlcs_command', {
gameId,
selectedDlcs,
}).catch((err) => {
console.error(`Error installing CreamLinux with selected DLCs:`, err)
throw err
})
// We don't need to manually close the dialog or update the game state
// because the backend will emit progress events that handle this
console.error(`Error installing CreamLinux with selected DLCs:`, err);
throw err;
});
}
} catch (error) {
console.error('Error processing DLC selection:', error)
console.error('Error processing DLC selection:', error);
// Show error in progress dialog
setProgressDialog((prev) => ({
...prev,
message: `Error: ${error}`,
progress: 100,
}))
}));
// Reset installing state
setGames((prevGames) =>
prevGames.map((g) => (g.id === gameId ? { ...g, installing: false } : g))
)
// ProgressDialog will handle exit animation automatically
);
}
}
};
// Update DLCs being streamed with enabled state
useEffect(() => {