mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 03:37:45 +03:00
fix: fixing remove installer button on downloads page
This commit is contained in:
parent
588cb983c2
commit
4f34743f94
@ -132,7 +132,7 @@
|
|||||||
"install": "Install",
|
"install": "Install",
|
||||||
"download_in_progress": "In progress",
|
"download_in_progress": "In progress",
|
||||||
"queued_downloads": "Queued downloads",
|
"queued_downloads": "Queued downloads",
|
||||||
"downloads_complete": "Completed",
|
"downloads_completed": "Completed",
|
||||||
"queued": "Queued"
|
"queued": "Queued"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
@ -130,7 +130,7 @@
|
|||||||
"install": "Instalar",
|
"install": "Instalar",
|
||||||
"download_in_progress": "Baixando agora",
|
"download_in_progress": "Baixando agora",
|
||||||
"queued_downloads": "Na fila",
|
"queued_downloads": "Na fila",
|
||||||
"downloads_complete": "Completo",
|
"downloads_completed": "Completo",
|
||||||
"queued": "Na fila"
|
"queued": "Na fila"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
@ -111,3 +111,9 @@ export const downloadActions = style({
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: `${SPACING_UNIT}px`,
|
gap: `${SPACING_UNIT}px`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const downloadGroup = style({
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: `${SPACING_UNIT * 2}px`,
|
||||||
|
});
|
@ -11,22 +11,28 @@ import {
|
|||||||
|
|
||||||
import { Downloader, formatBytes } from "@shared";
|
import { Downloader, formatBytes } from "@shared";
|
||||||
import { DOWNLOADER_NAME } from "@renderer/constants";
|
import { DOWNLOADER_NAME } from "@renderer/constants";
|
||||||
import { useAppSelector, useDownload, useLibrary } from "@renderer/hooks";
|
import { useAppSelector, useDownload } from "@renderer/hooks";
|
||||||
|
|
||||||
import * as styles from "./download-list.css";
|
import * as styles from "./download-group.css";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export interface DownloadListProps {
|
export interface DownloadGroupProps {
|
||||||
library: LibraryGame[];
|
library: LibraryGame[];
|
||||||
|
title: string;
|
||||||
|
openDeleteGameModal: (gameId: number) => void;
|
||||||
|
openGameInstaller: (gameId: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DownloadList({ library }: DownloadListProps) {
|
export function DownloadGroup({
|
||||||
|
library,
|
||||||
|
title,
|
||||||
|
openDeleteGameModal,
|
||||||
|
openGameInstaller,
|
||||||
|
}: DownloadGroupProps) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { t } = useTranslation("downloads");
|
const { t } = useTranslation("downloads");
|
||||||
|
|
||||||
const { updateLibrary } = useLibrary();
|
|
||||||
|
|
||||||
const userPreferences = useAppSelector(
|
const userPreferences = useAppSelector(
|
||||||
(state) => state.userPreferences.value
|
(state) => state.userPreferences.value
|
||||||
);
|
);
|
||||||
@ -38,16 +44,9 @@ export function DownloadList({ library }: DownloadListProps) {
|
|||||||
resumeDownload,
|
resumeDownload,
|
||||||
removeGameFromLibrary,
|
removeGameFromLibrary,
|
||||||
cancelDownload,
|
cancelDownload,
|
||||||
removeGameInstaller,
|
|
||||||
isGameDeleting,
|
isGameDeleting,
|
||||||
} = useDownload();
|
} = useDownload();
|
||||||
|
|
||||||
const openGameInstaller = (gameId: number) =>
|
|
||||||
window.electron.openGameInstaller(gameId).then((isBinaryInPath) => {
|
|
||||||
if (!isBinaryInPath) setShowBinaryNotFoundModal(true);
|
|
||||||
updateLibrary();
|
|
||||||
});
|
|
||||||
|
|
||||||
const getFinalDownloadSize = (game: LibraryGame) => {
|
const getFinalDownloadSize = (game: LibraryGame) => {
|
||||||
const isGameDownloading = lastPacket?.game.id === game.id;
|
const isGameDownloading = lastPacket?.game.id === game.id;
|
||||||
|
|
||||||
@ -114,11 +113,6 @@ export function DownloadList({ library }: DownloadListProps) {
|
|||||||
return <p>{t(game.status)}</p>;
|
return <p>{t(game.status)}</p>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const openDeleteModal = (gameId: number) => {
|
|
||||||
// gameToBeDeleted.current = gameId;
|
|
||||||
// setShowDeleteModal(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getGameActions = (game: LibraryGame) => {
|
const getGameActions = (game: LibraryGame) => {
|
||||||
const isGameDownloading = lastPacket?.game.id === game.id;
|
const isGameDownloading = lastPacket?.game.id === game.id;
|
||||||
|
|
||||||
@ -135,7 +129,7 @@ export function DownloadList({ library }: DownloadListProps) {
|
|||||||
{t("install")}
|
{t("install")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button onClick={() => openDeleteModal(game.id)} theme="outline">
|
<Button onClick={() => openDeleteGameModal(game.id)} theme="outline">
|
||||||
{t("delete")}
|
{t("delete")}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
@ -196,51 +190,57 @@ export function DownloadList({ library }: DownloadListProps) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!library.length) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className={styles.downloads}>
|
<div className={styles.downloadGroup}>
|
||||||
{library.map((game) => {
|
<h2>{title}</h2>
|
||||||
return (
|
|
||||||
<li
|
|
||||||
key={game.id}
|
|
||||||
className={styles.download({
|
|
||||||
cancelled: game.status === "removed",
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<div className={styles.downloadCover}>
|
|
||||||
<div className={styles.downloadCoverBackdrop}>
|
|
||||||
<img
|
|
||||||
src={steamUrlBuilder.library(game.objectID)}
|
|
||||||
className={styles.downloadCoverImage}
|
|
||||||
alt={game.title}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className={styles.downloadCoverContent}>
|
<ul className={styles.downloads}>
|
||||||
<Badge>{DOWNLOADER_NAME[game.downloader]}</Badge>
|
{library.map((game) => {
|
||||||
|
return (
|
||||||
|
<li
|
||||||
|
key={game.id}
|
||||||
|
className={styles.download({
|
||||||
|
cancelled: game.status === "removed",
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<div className={styles.downloadCover}>
|
||||||
|
<div className={styles.downloadCoverBackdrop}>
|
||||||
|
<img
|
||||||
|
src={steamUrlBuilder.library(game.objectID)}
|
||||||
|
className={styles.downloadCoverImage}
|
||||||
|
alt={game.title}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className={styles.downloadCoverContent}>
|
||||||
|
<Badge>{DOWNLOADER_NAME[game.downloader]}</Badge>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div className={styles.downloadRightContent}>
|
||||||
<div className={styles.downloadRightContent}>
|
<div className={styles.downloadDetails}>
|
||||||
<div className={styles.downloadDetails}>
|
<div className={styles.downloadTitleWrapper}>
|
||||||
<div className={styles.downloadTitleWrapper}>
|
<button
|
||||||
<button
|
type="button"
|
||||||
type="button"
|
className={styles.downloadTitle}
|
||||||
className={styles.downloadTitle}
|
onClick={() => navigate(buildGameDetailsPath(game))}
|
||||||
onClick={() => navigate(buildGameDetailsPath(game))}
|
>
|
||||||
>
|
{game.title}
|
||||||
{game.title}
|
</button>
|
||||||
</button>
|
</div>
|
||||||
|
|
||||||
|
{getGameInfo(game)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{getGameInfo(game)}
|
<div className={styles.downloadActions}>
|
||||||
|
{getGameActions(game)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</li>
|
||||||
<div className={styles.downloadActions}>
|
);
|
||||||
{getGameActions(game)}
|
})}
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
@ -13,9 +13,3 @@ export const downloadGroups = style({
|
|||||||
gap: `${SPACING_UNIT * 3}px`,
|
gap: `${SPACING_UNIT * 3}px`,
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const downloadGroup = style({
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
gap: `${SPACING_UNIT * 2}px`,
|
|
||||||
});
|
|
||||||
|
@ -6,12 +6,12 @@ import { useMemo, useRef, useState } from "react";
|
|||||||
import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal";
|
import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal";
|
||||||
import * as styles from "./downloads.css";
|
import * as styles from "./downloads.css";
|
||||||
import { DeleteGameModal } from "./delete-game-modal";
|
import { DeleteGameModal } from "./delete-game-modal";
|
||||||
import { DownloadList } from "./download-list";
|
import { DownloadGroup } from "./download-group";
|
||||||
import { LibraryGame } from "@types";
|
import { LibraryGame } from "@types";
|
||||||
import { orderBy } from "lodash-es";
|
import { orderBy } from "lodash-es";
|
||||||
|
|
||||||
export function Downloads() {
|
export function Downloads() {
|
||||||
const { library } = useLibrary();
|
const { library, updateLibrary } = useLibrary();
|
||||||
|
|
||||||
const { t } = useTranslation("downloads");
|
const { t } = useTranslation("downloads");
|
||||||
|
|
||||||
@ -29,6 +29,17 @@ export function Downloads() {
|
|||||||
|
|
||||||
const { lastPacket } = useDownload();
|
const { lastPacket } = useDownload();
|
||||||
|
|
||||||
|
const handleOpenGameInstaller = (gameId: number) =>
|
||||||
|
window.electron.openGameInstaller(gameId).then((isBinaryInPath) => {
|
||||||
|
if (!isBinaryInPath) setShowBinaryNotFoundModal(true);
|
||||||
|
updateLibrary();
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleOpenDeleteGameModal = (gameId: number) => {
|
||||||
|
gameToBeDeleted.current = gameId;
|
||||||
|
setShowDeleteModal(true);
|
||||||
|
};
|
||||||
|
|
||||||
const libraryGroup: Record<string, LibraryGame[]> = useMemo(() => {
|
const libraryGroup: Record<string, LibraryGame[]> = useMemo(() => {
|
||||||
const initialValue: Record<string, LibraryGame[]> = {
|
const initialValue: Record<string, LibraryGame[]> = {
|
||||||
downloading: [],
|
downloading: [],
|
||||||
@ -65,7 +76,20 @@ export function Downloads() {
|
|||||||
};
|
};
|
||||||
}, [library, lastPacket?.game.id]);
|
}, [library, lastPacket?.game.id]);
|
||||||
|
|
||||||
console.log(libraryGroup);
|
const downloadGroups = [
|
||||||
|
{
|
||||||
|
title: t("download_in_progress"),
|
||||||
|
library: libraryGroup.downloading,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("queued_downloads"),
|
||||||
|
library: libraryGroup.queued,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("downloads_completed"),
|
||||||
|
library: libraryGroup.complete,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={styles.downloadsContainer}>
|
<section className={styles.downloadsContainer}>
|
||||||
@ -81,26 +105,15 @@ export function Downloads() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div className={styles.downloadGroups}>
|
<div className={styles.downloadGroups}>
|
||||||
{libraryGroup.downloading.length > 0 && (
|
{downloadGroups.map((group) => (
|
||||||
<div className={styles.downloadGroup}>
|
<DownloadGroup
|
||||||
<h2>{t("download_in_progress")}</h2>
|
key={group.title}
|
||||||
<DownloadList library={libraryGroup.downloading} />
|
title={group.title}
|
||||||
</div>
|
library={group.library}
|
||||||
)}
|
openDeleteGameModal={handleOpenDeleteGameModal}
|
||||||
|
openGameInstaller={handleOpenGameInstaller}
|
||||||
{libraryGroup.queued.length > 0 && (
|
/>
|
||||||
<div className={styles.downloadGroup}>
|
))}
|
||||||
<h2>{t("queued_downloads")}</h2>
|
|
||||||
<DownloadList library={libraryGroup.queued} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{libraryGroup.complete.length > 0 && (
|
|
||||||
<div className={styles.downloadGroup}>
|
|
||||||
<h2>{t("downloads_complete")}</h2>
|
|
||||||
<DownloadList library={libraryGroup.complete} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user