feat: dont set game as removed when deleting instalation folder

This commit is contained in:
Zamitto 2024-06-04 17:33:21 -03:00
parent d6e57c20c7
commit 7ac7d92a28
5 changed files with 60 additions and 49 deletions

View file

@ -52,7 +52,6 @@ export function useDownload() {
try {
await window.electron.deleteGameFolder(gameId);
await window.electron.removeGame(gameId);
updateLibrary();
} finally {
dispatch(removeGameFromDeleting(gameId));

View file

@ -47,17 +47,21 @@ export function Downloads() {
complete: [],
};
const result = library.reduce((prev, next) => {
if (lastPacket?.game.id === next.id) {
return { ...prev, downloading: [...prev.downloading, next] };
}
const result = library
.filter((game) => {
return game.downloadPath;
})
.reduce((prev, next) => {
if (lastPacket?.game.id === next.id) {
return { ...prev, downloading: [...prev.downloading, next] };
}
if (next.downloadQueue || next.status === "paused") {
return { ...prev, queued: [...prev.queued, next] };
}
if (next.downloadQueue || next.status === "paused") {
return { ...prev, queued: [...prev.queued, next] };
}
return { ...prev, complete: [...prev.complete, next] };
}, initialValue);
return { ...prev, complete: [...prev.complete, next] };
}, initialValue);
const queued = orderBy(
result.queued,
@ -66,7 +70,7 @@ export function Downloads() {
);
const complete = orderBy(result.complete, (game) =>
game.status === "complete" ? 0 : 1
game.progress === 1 ? 0 : 1
);
return {

View file

@ -77,13 +77,11 @@ export function HeroPanelActions() {
if (game) {
await removeGameFromLibrary(game.id);
} else {
const gameExecutablePath = await selectGameExecutable();
await window.electron.addGameToLibrary(
objectID!,
gameTitle,
"steam",
gameExecutablePath
null
);
}
@ -110,11 +108,6 @@ export function HeroPanelActions() {
return;
}
if (game?.executablePath) {
window.electron.openGame(game.id, game.executablePath);
return;
}
const gameExecutablePath = await selectGameExecutable();
if (gameExecutablePath)
window.electron.openGame(game.id, gameExecutablePath);
@ -139,6 +132,17 @@ export function HeroPanelActions() {
</Button>
);
const showDownloadOptionsButton = (
<Button
onClick={openRepacksModal}
theme="outline"
disabled={deleting}
className={styles.heroPanelAction}
>
{t("open_download_options")}
</Button>
);
if (game?.status === "active" && game?.progress !== 1) {
return (
<>
@ -188,14 +192,7 @@ export function HeroPanelActions() {
if (game?.status === "removed") {
return (
<>
<Button
onClick={openRepacksModal}
theme="outline"
disabled={deleting}
className={styles.heroPanelAction}
>
{t("open_download_options")}
</Button>
{showDownloadOptionsButton}
<Button
onClick={() => removeGameFromLibrary(game.id).then(updateGame)}
@ -227,7 +224,7 @@ export function HeroPanelActions() {
if (game) {
return (
<>
{game?.progress === 1 ? (
{game?.progress === 1 && game?.folderName && (
<>
<BinaryNotFoundModal
visible={showBinaryNotFoundModal}
@ -243,10 +240,12 @@ export function HeroPanelActions() {
{t("install")}
</Button>
</>
) : (
toggleGameOnLibraryButton
)}
{game?.progress === 1 && !game?.folderName && showDownloadOptionsButton}
{game?.progress !== 1 && toggleGameOnLibraryButton}
{isGameRunning ? (
<Button
onClick={closeGame}