feat: adding last selected option to repacks modal

This commit is contained in:
Chubby Granny Chaser 2024-06-08 19:18:24 +01:00
parent 80a25bf409
commit d700e2706c
No known key found for this signature in database
4 changed files with 26 additions and 6 deletions

View File

@ -117,7 +117,8 @@
"danger_zone_section_title": "Danger zone",
"danger_zone_section_description": "Remove this game from your library or the files downloaded by Hydra",
"download_in_progress": "Download in progress",
"download_paused": "Download paused"
"download_paused": "Download paused",
"last_selected_option": "Last selected option"
},
"activation": {
"title": "Activate Hydra",

View File

@ -114,7 +114,8 @@
"danger_zone_section_title": "Zona de perigo",
"danger_zone_section_description": "Remova o jogo da sua biblioteca ou os arquivos que foram baixados pelo Hydra",
"download_in_progress": "Download em andamento",
"download_paused": "Download pausado"
"download_paused": "Download pausado",
"last_selected_option": "Última opção selecionada"
},
"activation": {
"title": "Ativação",

View File

@ -1,7 +1,8 @@
import { useContext, useEffect, useState } from "react";
import { useCallback, useContext, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import parseTorrent from "parse-torrent";
import { Button, Modal, TextField } from "@renderer/components";
import { Badge, Button, Modal, TextField } from "@renderer/components";
import type { GameRepack } from "@types";
import * as styles from "./repacks-modal.css";
@ -31,13 +32,22 @@ export function RepacksModal({
const [repack, setRepack] = useState<GameRepack | null>(null);
const [showSelectFolderModal, setShowSelectFolderModal] = useState(false);
const { repacks } = useContext(gameDetailsContext);
const [infoHash, setInfoHash] = useState("");
const { repacks, game } = useContext(gameDetailsContext);
const { t } = useTranslation("game_details");
const getInfoHash = useCallback(async () => {
const torrent = await parseTorrent(game?.uri ?? "");
setInfoHash(torrent.infoHash ?? "");
}, [game]);
useEffect(() => {
setFilteredRepacks(repacks);
}, [repacks, visible]);
if (game?.uri) getInfoHash();
}, [repacks, visible, game, getInfoHash]);
const handleRepackClick = (repack: GameRepack) => {
setRepack(repack);
@ -59,6 +69,8 @@ export function RepacksModal({
);
};
console.log(infoHash);
return (
<>
<DownloadSettingsModal
@ -89,6 +101,11 @@ export function RepacksModal({
<p style={{ color: "#DADBE1", wordBreak: "break-word" }}>
{repack.title}
</p>
{repack.magnet.toLowerCase().includes(infoHash) && (
<Badge>{t("last_selected_option")}</Badge>
)}
<p style={{ fontSize: "12px" }}>
{repack.fileSize} - {repack.repacker} -{" "}
{repack.uploadDate

View File

@ -107,6 +107,7 @@ export interface Game {
downloader: Downloader;
executablePath: string | null;
lastTimePlayed: Date | null;
uri: string | null;
fileSize: number;
objectID: string;
shop: GameShop;