mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
fix: showing multiple download options
This commit is contained in:
parent
c218070463
commit
42ea35441c
17 changed files with 118 additions and 98 deletions
|
@ -22,9 +22,10 @@ export function useDownload() {
|
|||
);
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const startDownload = (payload: StartGameDownloadPayload) => {
|
||||
const startDownload = async (payload: StartGameDownloadPayload) => {
|
||||
dispatch(clearDownload());
|
||||
window.electron.startGameDownload(payload).then((game) => {
|
||||
|
||||
return window.electron.startGameDownload(payload).then((game) => {
|
||||
updateLibrary();
|
||||
|
||||
return game;
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
} from "@renderer/context";
|
||||
import { useDownload } from "@renderer/hooks";
|
||||
import { GameOptionsModal, RepacksModal } from "./modals";
|
||||
import { Downloader } from "@shared";
|
||||
import { Downloader, getDownloadersForUri } from "@shared";
|
||||
|
||||
export function GameDetails() {
|
||||
const [randomGame, setRandomGame] = useState<Steam250Game | null>(null);
|
||||
|
@ -70,6 +70,9 @@ export function GameDetails() {
|
|||
}
|
||||
};
|
||||
|
||||
const selectRepackUri = (repack: GameRepack, downloader: Downloader) =>
|
||||
repack.uris.find((uri) => getDownloadersForUri(uri).includes(downloader))!;
|
||||
|
||||
return (
|
||||
<GameDetailsContextProvider>
|
||||
<GameDetailsContextConsumer>
|
||||
|
@ -96,6 +99,7 @@ export function GameDetails() {
|
|||
downloader,
|
||||
shop: shop as GameShop,
|
||||
downloadPath,
|
||||
uri: selectRepackUri(repack, downloader),
|
||||
});
|
||||
|
||||
await updateGame();
|
||||
|
|
|
@ -5,7 +5,7 @@ import { DiskSpace } from "check-disk-space";
|
|||
import * as styles from "./download-settings-modal.css";
|
||||
import { Button, Link, Modal, TextField } from "@renderer/components";
|
||||
import { CheckCircleFillIcon, DownloadIcon } from "@primer/octicons-react";
|
||||
import { Downloader, formatBytes, getDownloadersForUri } from "@shared";
|
||||
import { Downloader, formatBytes, getDownloadersForUris } from "@shared";
|
||||
|
||||
import type { GameRepack } from "@types";
|
||||
import { SPACING_UNIT } from "@renderer/theme.css";
|
||||
|
@ -48,8 +48,8 @@ export function DownloadSettingsModal({
|
|||
}, [visible, selectedPath]);
|
||||
|
||||
const downloaders = useMemo(() => {
|
||||
return getDownloadersForUri(repack?.magnet ?? "");
|
||||
}, [repack?.magnet]);
|
||||
return getDownloadersForUris(repack?.uris ?? []);
|
||||
}, [repack?.uris]);
|
||||
|
||||
useEffect(() => {
|
||||
if (userPreferences?.downloadsPath) {
|
||||
|
|
|
@ -76,6 +76,13 @@ export function RepacksModal({
|
|||
);
|
||||
};
|
||||
|
||||
const checkIfLastDownloadedOption = (repack: GameRepack) => {
|
||||
if (infoHash) return repack.uris.some((uri) => uri.includes(infoHash));
|
||||
if (!game?.uri) return false;
|
||||
|
||||
return repack.uris.some((uri) => uri.includes(game?.uri ?? ""));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DownloadSettingsModal
|
||||
|
@ -97,9 +104,7 @@ export function RepacksModal({
|
|||
|
||||
<div className={styles.repacks}>
|
||||
{filteredRepacks.map((repack) => {
|
||||
const isLastDownloadedOption =
|
||||
infoHash !== null &&
|
||||
repack.magnet.toLowerCase().includes(infoHash);
|
||||
const isLastDownloadedOption = checkIfLastDownloadedOption(repack);
|
||||
|
||||
return (
|
||||
<Button
|
||||
|
|
|
@ -42,10 +42,3 @@ export const downloadSourcesHeader = style({
|
|||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
});
|
||||
|
||||
export const separator = style({
|
||||
height: "100%",
|
||||
width: "1px",
|
||||
backgroundColor: vars.color.border,
|
||||
margin: `${SPACING_UNIT}px 0`,
|
||||
});
|
||||
|
|
|
@ -134,15 +134,6 @@ export function SettingsDownloadSources() {
|
|||
downloadSource.downloadCount.toLocaleString(),
|
||||
})}
|
||||
</small>
|
||||
|
||||
<div className={styles.separator} />
|
||||
|
||||
<small>
|
||||
{t("download_options", {
|
||||
count: downloadSource.repackCount,
|
||||
countFormatted: downloadSource.repackCount.toLocaleString(),
|
||||
})}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue