From a1e41ea464937f213206c9d93d5caf740f4a88d8 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Thu, 27 Jun 2024 19:59:33 +0100 Subject: [PATCH] feat: adding file verification message --- src/locales/en/translation.json | 6 ++++-- src/locales/pt/translation.json | 6 ++++-- .../src/components/bottom-panel/bottom-panel.tsx | 5 ++++- src/renderer/src/components/sidebar/sidebar.tsx | 15 ++++++++++----- src/renderer/src/hooks/use-download.ts | 2 +- .../src/pages/downloads/download-group.tsx | 13 +++++++++++++ 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 6746752a..9799b12e 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -36,7 +36,8 @@ "no_downloads_in_progress": "No downloads in progress", "downloading_metadata": "Downloading {{title}} metadata…", "downloading": "Downloading {{title}}… ({{percentage}} complete) - Conclusion {{eta}} - {{speed}}", - "calculating_eta": "Downloading {{title}}… ({{percentage}} complete) - Calculating remaining time…" + "calculating_eta": "Downloading {{title}}… ({{percentage}} complete) - Calculating remaining time…", + "checking_files": "Checking {{title}} files… ({{percentage}} complete)" }, "catalogue": { "next_page": "Next page", @@ -144,7 +145,8 @@ "downloads_completed": "Completed", "queued": "Queued", "no_downloads_title": "Such empty", - "no_downloads_description": "You haven't downloaded anything with Hydra yet, but it's never too late to start." + "no_downloads_description": "You haven't downloaded anything with Hydra yet, but it's never too late to start.", + "checking_files": "Checking files…" }, "settings": { "downloads_path": "Downloads path", diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json index 2520178a..eda98d77 100644 --- a/src/locales/pt/translation.json +++ b/src/locales/pt/translation.json @@ -36,7 +36,8 @@ "no_downloads_in_progress": "Sem downloads em andamento", "downloading_metadata": "Baixando metadados de {{title}}…", "downloading": "Baixando {{title}}… ({{percentage}} concluído) - Conclusão {{eta}} - {{speed}}", - "calculating_eta": "Baixando {{title}}… ({{percentage}} concluído) - Calculando tempo restante…" + "calculating_eta": "Baixando {{title}}… ({{percentage}} concluído) - Calculando tempo restante…", + "checking_files": "Verificando arquivos de {{title}}…" }, "game_details": { "open_download_options": "Ver opções de download", @@ -140,7 +141,8 @@ "downloads_completed": "Completo", "queued": "Na fila", "no_downloads_title": "Nada por aqui…", - "no_downloads_description": "Você ainda não baixou nada pelo Hydra, mas nunca é tarde para começar." + "no_downloads_description": "Você ainda não baixou nada pelo Hydra, mas nunca é tarde para começar.", + "checking_files": "Verificando arquivos…" }, "settings": { "downloads_path": "Diretório dos downloads", diff --git a/src/renderer/src/components/bottom-panel/bottom-panel.tsx b/src/renderer/src/components/bottom-panel/bottom-panel.tsx index 980c528e..0d28a26e 100644 --- a/src/renderer/src/components/bottom-panel/bottom-panel.tsx +++ b/src/renderer/src/components/bottom-panel/bottom-panel.tsx @@ -39,7 +39,10 @@ export function BottomPanel() { }); if (lastPacket?.isDownloadingMetadata) - return t("downloading_metadata", { title: lastPacket?.game.title }); + return t("downloading_metadata", { + title: lastPacket?.game.title, + percentage: progress, + }); if (!eta) { return t("calculating_eta", { diff --git a/src/renderer/src/components/sidebar/sidebar.tsx b/src/renderer/src/components/sidebar/sidebar.tsx index 5fb20577..c5b3f3a9 100644 --- a/src/renderer/src/components/sidebar/sidebar.tsx +++ b/src/renderer/src/components/sidebar/sidebar.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { useLocation, useNavigate } from "react-router-dom"; @@ -14,6 +14,7 @@ import { buildGameDetailsPath } from "@renderer/helpers"; import SteamLogo from "@renderer/assets/steam-logo.svg?react"; import { SidebarProfile } from "./sidebar-profile"; +import { sortBy } from "lodash-es"; const SIDEBAR_MIN_WIDTH = 200; const SIDEBAR_INITIAL_WIDTH = 250; @@ -35,6 +36,10 @@ export function Sidebar() { const location = useLocation(); + const sortedLibrary = useMemo(() => { + return sortBy(library, (game) => game.title); + }, [library]); + const { lastPacket, progress } = useDownload(); const { showWarningToast } = useToast(); @@ -43,7 +48,7 @@ export function Sidebar() { updateLibrary(); }, [lastPacket?.game.id, updateLibrary]); - const isDownloading = library.some( + const isDownloading = sortedLibrary.some( (game) => game.status === "active" && game.progress !== 1 ); @@ -63,7 +68,7 @@ export function Sidebar() { const handleFilter: React.ChangeEventHandler = (event) => { setFilteredLibrary( - library.filter((game) => + sortedLibrary.filter((game) => game.title .toLowerCase() .includes(event.target.value.toLocaleLowerCase()) @@ -72,8 +77,8 @@ export function Sidebar() { }; useEffect(() => { - setFilteredLibrary(library); - }, [library]); + setFilteredLibrary(sortedLibrary); + }, [sortedLibrary]); useEffect(() => { window.onmousemove = (event: MouseEvent) => { diff --git a/src/renderer/src/hooks/use-download.ts b/src/renderer/src/hooks/use-download.ts index 8db5fc03..4e4f9dbf 100644 --- a/src/renderer/src/hooks/use-download.ts +++ b/src/renderer/src/hooks/use-download.ts @@ -85,7 +85,7 @@ export function useDownload() { return { downloadSpeed: `${formatBytes(lastPacket?.downloadSpeed ?? 0)}/s`, - progress: formatDownloadProgress(lastPacket?.game.progress), + progress: formatDownloadProgress(lastPacket?.progress ?? 0), lastPacket, eta: getETA(), startDownload, diff --git a/src/renderer/src/pages/downloads/download-group.tsx b/src/renderer/src/pages/downloads/download-group.tsx index b2c73890..ae2605ec 100644 --- a/src/renderer/src/pages/downloads/download-group.tsx +++ b/src/renderer/src/pages/downloads/download-group.tsx @@ -67,6 +67,19 @@ export function DownloadGroup({ } if (isGameDownloading) { + if (lastPacket?.isDownloadingMetadata) { + return

{t("downloading_metadata")}

; + } + + if (lastPacket?.isCheckingFiles) { + return ( + <> +

{progress}

+

{t("checking_files")}

+ + ); + } + return ( <>

{progress}