From 43e9919b6b437f8ed412c9a56e0e17c1fbf9a4a7 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Fri, 27 Sep 2024 03:39:42 +0100 Subject: [PATCH] fix: adding direct comparison last downloaded option --- .../game-details/modals/repacks-modal.tsx | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/renderer/src/pages/game-details/modals/repacks-modal.tsx b/src/renderer/src/pages/game-details/modals/repacks-modal.tsx index 0d1b9c1d..9d8a1a11 100644 --- a/src/renderer/src/pages/game-details/modals/repacks-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/repacks-modal.tsx @@ -1,6 +1,5 @@ -import { useCallback, useContext, useEffect, useMemo, useState } from "react"; +import { useContext, useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; -import parseTorrent from "parse-torrent"; import { Badge, Button, Modal, TextField } from "@renderer/components"; import type { GameRepack } from "@types"; @@ -33,8 +32,6 @@ export function RepacksModal({ const [repack, setRepack] = useState(null); const [showSelectFolderModal, setShowSelectFolderModal] = useState(false); - const [infoHash, setInfoHash] = useState(null); - const { repacks, game } = useContext(gameDetailsContext); const { t } = useTranslation("game_details"); @@ -43,18 +40,9 @@ export function RepacksModal({ return orderBy(repacks, (repack) => repack.uploadDate, "desc"); }, [repacks]); - const getInfoHash = useCallback(async () => { - if (game?.uri?.startsWith("magnet:")) { - const torrent = await parseTorrent(game?.uri ?? ""); - if (torrent.infoHash) setInfoHash(torrent.infoHash); - } - }, [game]); - useEffect(() => { setFilteredRepacks(sortedRepacks); - - if (game?.uri) getInfoHash(); - }, [sortedRepacks, visible, game, getInfoHash]); + }, [sortedRepacks, visible, game]); const handleRepackClick = (repack: GameRepack) => { setRepack(repack); @@ -77,9 +65,6 @@ 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 ?? "")); };