refactor: change file name

This commit is contained in:
JackEnx 2024-04-18 17:17:07 -03:00
parent 18bb9e9526
commit 4619198051
6 changed files with 15 additions and 15 deletions

View File

@ -11,7 +11,7 @@ import {
} from "@renderer/features"; } from "@renderer/features";
import type { GameShop, TorrentProgress } from "@types"; import type { GameShop, TorrentProgress } from "@types";
import { useDate } from "./use-date"; import { useDate } from "./use-date";
import { byteFormat } from "@renderer/utils"; import { formatBytes } from "@renderer/utils";
export function useDownload() { export function useDownload() {
const { updateLibrary } = useLibrary(); const { updateLibrary } = useLibrary();
@ -113,7 +113,7 @@ export function useDownload() {
fileSize: lastPacket?.game.fileSize, fileSize: lastPacket?.game.fileSize,
isVerifying, isVerifying,
gameId: lastPacket?.game.id, gameId: lastPacket?.game.id,
downloadSpeed: `${byteFormat(lastPacket?.downloadSpeed ?? 0)}/s`, downloadSpeed: `${formatBytes(lastPacket?.downloadSpeed ?? 0)}/s`,
isDownloading: Boolean(lastPacket), isDownloading: Boolean(lastPacket),
progress: getProgress(), progress: getProgress(),
numPeers: lastPacket?.numPeers, numPeers: lastPacket?.numPeers,

View File

@ -10,7 +10,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal"; import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal";
import * as styles from "./downloads.css"; import * as styles from "./downloads.css";
import { DeleteModal } from "./delete-modal"; import { DeleteModal } from "./delete-modal";
import { byteFormat } from "@renderer/utils"; import { formatBytes } from "@renderer/utils";
export function Downloads() { export function Downloads() {
const { library, updateLibrary } = useLibrary(); const { library, updateLibrary } = useLibrary();
@ -61,10 +61,10 @@ export function Downloads() {
const isGameDownloading = isDownloading && gameDownloading?.id === game?.id; const isGameDownloading = isDownloading && gameDownloading?.id === game?.id;
if (!game) return "N/A"; if (!game) return "N/A";
if (game.fileSize) return byteFormat(game.fileSize); if (game.fileSize) return formatBytes(game.fileSize);
if (gameDownloading?.fileSize && isGameDownloading) if (gameDownloading?.fileSize && isGameDownloading)
return byteFormat(gameDownloading.fileSize); return formatBytes(gameDownloading.fileSize);
return game.repack?.fileSize ?? "N/A"; return game.repack?.fileSize ?? "N/A";
}; };
@ -87,7 +87,7 @@ export function Downloads() {
) : ( ) : (
<> <>
<p> <p>
{byteFormat(gameDownloading?.bytesDownloaded)} /{" "} {formatBytes(gameDownloading?.bytesDownloaded)} /{" "}
{finalDownloadSize} {finalDownloadSize}
</p> </p>
<p> <p>

View File

@ -11,7 +11,7 @@ import { NoEntryIcon, PlusCircleIcon } from "@primer/octicons-react";
import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal"; import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal";
import * as styles from "./hero-panel.css"; import * as styles from "./hero-panel.css";
import { useDate } from "@renderer/hooks/use-date"; import { useDate } from "@renderer/hooks/use-date";
import { byteFormat } from "@renderer/utils"; import { formatBytes } from "@renderer/utils";
export interface HeroPanelProps { export interface HeroPanelProps {
game: Game | null; game: Game | null;
@ -120,10 +120,10 @@ export function HeroPanel({
const finalDownloadSize = useMemo(() => { const finalDownloadSize = useMemo(() => {
if (!game) return "N/A"; if (!game) return "N/A";
if (game.fileSize) return byteFormat(game.fileSize); if (game.fileSize) return formatBytes(game.fileSize);
if (gameDownloading?.fileSize && isGameDownloading) if (gameDownloading?.fileSize && isGameDownloading)
return byteFormat(gameDownloading.fileSize); return formatBytes(gameDownloading.fileSize);
return game.repack?.fileSize ?? "N/A"; return game.repack?.fileSize ?? "N/A";
}, [game, isGameDownloading, gameDownloading]); }, [game, isGameDownloading, gameDownloading]);
@ -170,7 +170,7 @@ export function HeroPanel({
</> </>
) : ( ) : (
<p className={styles.downloadDetailsRow}> <p className={styles.downloadDetailsRow}>
{byteFormat(gameDownloading?.bytesDownloaded)} /{" "} {formatBytes(gameDownloading?.bytesDownloaded)} /{" "}
{finalDownloadSize} {finalDownloadSize}
<small> <small>
{numPeers} peers / {numSeeds} seeds {numPeers} peers / {numSeeds} seeds
@ -190,7 +190,7 @@ export function HeroPanel({
})} })}
</p> </p>
<p> <p>
{byteFormat(game.bytesDownloaded)} / {finalDownloadSize} {formatBytes(game.bytesDownloaded)} / {finalDownloadSize}
</p> </p>
</> </>
); );

View File

@ -9,7 +9,7 @@ import * as styles from "./repacks-modal.css";
import type { DiskSpace } from "check-disk-space"; import type { DiskSpace } from "check-disk-space";
import { format } from "date-fns"; import { format } from "date-fns";
import { SPACING_UNIT } from "@renderer/theme.css"; import { SPACING_UNIT } from "@renderer/theme.css";
import { byteFormat } from "@renderer/utils"; import { formatBytes } from "@renderer/utils";
export interface RepacksModalProps { export interface RepacksModalProps {
visible: boolean; visible: boolean;
@ -66,7 +66,7 @@ export function RepacksModal({
visible={visible} visible={visible}
title={`${gameDetails.name} Repacks`} title={`${gameDetails.name} Repacks`}
description={t("space_left_on_disk", { description={t("space_left_on_disk", {
space: byteFormat(diskFreeSpace?.free ?? 0), space: formatBytes(diskFreeSpace?.free ?? 0),
})} })}
onClose={onClose} onClose={onClose}
> >

View File

@ -1,6 +1,6 @@
const FORMAT = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; const FORMAT = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
export const byteFormat = (bytes: number): string => { export const formatBytes = (bytes: number): string => {
if (!Number.isFinite(bytes) || isNaN(bytes) || bytes < 0) { if (!Number.isFinite(bytes) || isNaN(bytes) || bytes < 0) {
return `N/A ${FORMAT[0]}`; return `N/A ${FORMAT[0]}`;
} }

View File

@ -1 +1 @@
export * from "./byteFormat"; export * from "./format-bytes";