mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 08:43:48 +03:00
feat: change diskFreeSpace from rapacks modal to select folder modal description
This commit is contained in:
parent
35927b8784
commit
37e9ea71c6
@ -79,7 +79,7 @@
|
|||||||
"close": "Close",
|
"close": "Close",
|
||||||
"playing_now": "Playing now",
|
"playing_now": "Playing now",
|
||||||
"change": "Change",
|
"change": "Change",
|
||||||
"select_folder_description": "Select the folder where the game will be installed",
|
"repacks_modal_description": "Choose the repack you want to download",
|
||||||
"downloads_path": "Downloads path",
|
"downloads_path": "Downloads path",
|
||||||
"select_folder_hint": "To change the default folder, access the",
|
"select_folder_hint": "To change the default folder, access the",
|
||||||
"hydra_settings": "Hydra settings",
|
"hydra_settings": "Hydra settings",
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
"deleting": "Excluindo instalador…",
|
"deleting": "Excluindo instalador…",
|
||||||
"playing_now": "Jogando agora",
|
"playing_now": "Jogando agora",
|
||||||
"change": "Mudar",
|
"change": "Mudar",
|
||||||
"select_folder_description": "Selecione a pasta em que o jogo será baixado",
|
"repacks_modal_description": "Escolha o repack do jogo que deseja baixar",
|
||||||
"downloads_path": "Diretório do download",
|
"downloads_path": "Diretório do download",
|
||||||
"select_folder_hint": "Para trocar a pasta padrão, acesse as ",
|
"select_folder_hint": "Para trocar a pasta padrão, acesse as ",
|
||||||
"hydra_settings": "Configurações do Hydra",
|
"hydra_settings": "Configurações do Hydra",
|
||||||
|
2
src/renderer/declaration.d.ts
vendored
2
src/renderer/declaration.d.ts
vendored
@ -76,7 +76,7 @@ declare global {
|
|||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
|
|
||||||
/* Hardware */
|
/* Hardware */
|
||||||
getDiskFreeSpace: () => Promise<DiskSpace>;
|
getDiskFreeSpace: (path: string) => Promise<DiskSpace>;
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
getOrCacheImage: (url: string) => Promise<string>;
|
getOrCacheImage: (url: string) => Promise<string>;
|
||||||
|
@ -19,15 +19,15 @@ import { useAppDispatch, useDownload } from "@renderer/hooks";
|
|||||||
import starsAnimation from "@renderer/assets/lottie/stars.json";
|
import starsAnimation from "@renderer/assets/lottie/stars.json";
|
||||||
|
|
||||||
import { vars } from "@renderer/theme.css";
|
import { vars } from "@renderer/theme.css";
|
||||||
|
import Lottie from "lottie-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { SkeletonTheme } from "react-loading-skeleton";
|
import { SkeletonTheme } from "react-loading-skeleton";
|
||||||
|
import { DescriptionHeader } from "./description-header";
|
||||||
import { GameDetailsSkeleton } from "./game-details-skeleton";
|
import { GameDetailsSkeleton } from "./game-details-skeleton";
|
||||||
import * as styles from "./game-details.css";
|
import * as styles from "./game-details.css";
|
||||||
import { HeroPanel } from "./hero-panel";
|
import { HeroPanel } from "./hero-panel";
|
||||||
import { HowLongToBeatSection } from "./how-long-to-beat-section";
|
import { HowLongToBeatSection } from "./how-long-to-beat-section";
|
||||||
import { RepacksModal } from "./repacks-modal";
|
import { RepacksModal } from "./repacks-modal";
|
||||||
import Lottie from "lottie-react";
|
|
||||||
import { DescriptionHeader } from "./description-header";
|
|
||||||
|
|
||||||
export function GameDetails() {
|
export function GameDetails() {
|
||||||
const { objectID, shop } = useParams();
|
const { objectID, shop } = useParams();
|
||||||
|
@ -6,11 +6,9 @@ import type { GameRepack, ShopDetails } from "@types";
|
|||||||
|
|
||||||
import * as styles from "./repacks-modal.css";
|
import * as styles from "./repacks-modal.css";
|
||||||
|
|
||||||
import type { DiskSpace } from "check-disk-space";
|
|
||||||
import { format } from "date-fns";
|
|
||||||
import { SPACING_UNIT } from "@renderer/theme.css";
|
|
||||||
import { formatBytes } from "@renderer/utils";
|
|
||||||
import { useAppSelector } from "@renderer/hooks";
|
import { useAppSelector } from "@renderer/hooks";
|
||||||
|
import { SPACING_UNIT } from "@renderer/theme.css";
|
||||||
|
import { format } from "date-fns";
|
||||||
import { SelectFolderModal } from "./select-folder-modal";
|
import { SelectFolderModal } from "./select-folder-modal";
|
||||||
|
|
||||||
export interface RepacksModalProps {
|
export interface RepacksModalProps {
|
||||||
@ -30,7 +28,6 @@ export function RepacksModal({
|
|||||||
startDownload,
|
startDownload,
|
||||||
onClose,
|
onClose,
|
||||||
}: RepacksModalProps) {
|
}: RepacksModalProps) {
|
||||||
const [diskFreeSpace, setDiskFreeSpace] = useState<DiskSpace>(null);
|
|
||||||
const [filteredRepacks, setFilteredRepacks] = useState<GameRepack[]>([]);
|
const [filteredRepacks, setFilteredRepacks] = useState<GameRepack[]>([]);
|
||||||
const [repack, setRepack] = useState<GameRepack>(null);
|
const [repack, setRepack] = useState<GameRepack>(null);
|
||||||
|
|
||||||
@ -44,16 +41,6 @@ export function RepacksModal({
|
|||||||
setFilteredRepacks(gameDetails.repacks);
|
setFilteredRepacks(gameDetails.repacks);
|
||||||
}, [gameDetails.repacks]);
|
}, [gameDetails.repacks]);
|
||||||
|
|
||||||
const getDiskFreeSpace = () => {
|
|
||||||
window.electron.getDiskFreeSpace().then((result) => {
|
|
||||||
setDiskFreeSpace(result);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
getDiskFreeSpace();
|
|
||||||
}, [visible]);
|
|
||||||
|
|
||||||
const handleRepackClick = (repack: GameRepack) => {
|
const handleRepackClick = (repack: GameRepack) => {
|
||||||
setRepack(repack);
|
setRepack(repack);
|
||||||
setShowSelectFolderModal(true);
|
setShowSelectFolderModal(true);
|
||||||
@ -73,9 +60,7 @@ export function RepacksModal({
|
|||||||
<Modal
|
<Modal
|
||||||
visible={visible}
|
visible={visible}
|
||||||
title={`${gameDetails.name} Repacks`}
|
title={`${gameDetails.name} Repacks`}
|
||||||
description={t("space_left_on_disk", {
|
description={t("repacks_modal_description")}
|
||||||
space: formatBytes(diskFreeSpace?.free ?? 0),
|
|
||||||
})}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
>
|
>
|
||||||
<SelectFolderModal
|
<SelectFolderModal
|
||||||
|
@ -3,8 +3,10 @@ import { GameRepack, ShopDetails } from "@types";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import * as styles from "./select-folder-modal.css";
|
import { formatBytes } from "@renderer/utils";
|
||||||
|
import { DiskSpace } from "check-disk-space";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import * as styles from "./select-folder-modal.css";
|
||||||
|
|
||||||
export interface SelectFolderModalProps {
|
export interface SelectFolderModalProps {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
@ -23,9 +25,14 @@ export function SelectFolderModal({
|
|||||||
}: SelectFolderModalProps) {
|
}: SelectFolderModalProps) {
|
||||||
const { t } = useTranslation("game_details");
|
const { t } = useTranslation("game_details");
|
||||||
|
|
||||||
|
const [diskFreeSpace, setDiskFreeSpace] = useState<DiskSpace>(null);
|
||||||
const [selectedPath, setSelectedPath] = useState("");
|
const [selectedPath, setSelectedPath] = useState("");
|
||||||
const [downloadStarting, setDownloadStarting] = useState(false);
|
const [downloadStarting, setDownloadStarting] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
visible && getDiskFreeSpace(selectedPath);
|
||||||
|
}, [visible, selectedPath]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
window.electron.getDefaultDownloadsPath(),
|
window.electron.getDefaultDownloadsPath(),
|
||||||
@ -35,6 +42,12 @@ export function SelectFolderModal({
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const getDiskFreeSpace = (path: string) => {
|
||||||
|
window.electron.getDiskFreeSpace(path).then((result) => {
|
||||||
|
setDiskFreeSpace(result);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleChooseDownloadsPath = async () => {
|
const handleChooseDownloadsPath = async () => {
|
||||||
const { filePaths } = await window.electron.showOpenDialog({
|
const { filePaths } = await window.electron.showOpenDialog({
|
||||||
defaultPath: selectedPath,
|
defaultPath: selectedPath,
|
||||||
@ -58,7 +71,9 @@ export function SelectFolderModal({
|
|||||||
<Modal
|
<Modal
|
||||||
visible={visible}
|
visible={visible}
|
||||||
title={`${gameDetails.name} Installation folder`}
|
title={`${gameDetails.name} Installation folder`}
|
||||||
description={t("select_folder_description")}
|
description={t("space_left_on_disk", {
|
||||||
|
space: formatBytes(diskFreeSpace?.free ?? 0),
|
||||||
|
})}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
>
|
>
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
|
Loading…
Reference in New Issue
Block a user