cancel download before remove game from library

This commit is contained in:
Zamitto 2024-06-08 11:24:26 -03:00
parent e3d0ef598b
commit cc9a38acf8
2 changed files with 14 additions and 7 deletions

View file

@ -63,7 +63,6 @@ export const button = styleVariants({
color: "white", color: "white",
":hover": { ":hover": {
backgroundColor: "#a31533", backgroundColor: "#a31533",
color: "white",
}, },
}, },
], ],

View file

@ -28,8 +28,12 @@ export function GameOptionsModal({
const [showDeleteModal, setShowDeleteModal] = useState(false); const [showDeleteModal, setShowDeleteModal] = useState(false);
const [showRemoveGameModal, setShowRemoveGameModal] = useState(false); const [showRemoveGameModal, setShowRemoveGameModal] = useState(false);
const { removeGameInstaller, removeGameFromLibrary, isGameDeleting } = const {
useDownload(); removeGameInstaller,
removeGameFromLibrary,
isGameDeleting,
cancelDownload,
} = useDownload();
const deleting = game ? isGameDeleting(game?.id) : false; const deleting = game ? isGameDeleting(game?.id) : false;
@ -39,16 +43,20 @@ export function GameOptionsModal({
game?.status === "active" && lastPacket?.game.id === game?.id; game?.status === "active" && lastPacket?.game.id === game?.id;
const handleRemoveGameFromLibrary = async () => { const handleRemoveGameFromLibrary = async () => {
if (isGameDownloading) {
await cancelDownload(game.id);
}
await removeGameFromLibrary(game.id); await removeGameFromLibrary(game.id);
updateGame(); updateGame();
onClose(); onClose();
}; };
const handleChangeExecutableLocation = async () => { const handleChangeExecutableLocation = async () => {
const location = await selectGameExecutable(); const path = await selectGameExecutable();
if (location) { if (path) {
await window.electron.updateExecutablePath(game.id, location); await window.electron.updateExecutablePath(game.id, path);
updateGame(); updateGame();
} }
}; };
@ -145,7 +153,7 @@ export function GameOptionsModal({
<Button <Button
onClick={openRepacksModal} onClick={openRepacksModal}
theme="outline" theme="outline"
disabled={deleting} disabled={deleting || isGameDownloading}
> >
{t("open_download_options")} {t("open_download_options")}
</Button> </Button>