From 51bcd82ea75d35f25ec7821ff670a628e4759f83 Mon Sep 17 00:00:00 2001 From: 0x6d61726b <0x6d61726b@gmail.com> Date: Sun, 3 Mar 2024 15:48:56 +0100 Subject: [PATCH] Fixed human-readable file size representation (#137) (as it follows units of IEC 60027-2 A.2 ) --- frontend/src/components/DownloadCard.tsx | 4 ++-- frontend/src/components/DownloadsListView.tsx | 4 ++-- frontend/src/components/FreeSpaceIndicator.tsx | 4 ++-- frontend/src/utils.ts | 17 ++++++++++++----- frontend/src/views/Archive.tsx | 4 ++-- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/DownloadCard.tsx b/frontend/src/components/DownloadCard.tsx index 9789ba8..9f47a90 100644 --- a/frontend/src/components/DownloadCard.tsx +++ b/frontend/src/components/DownloadCard.tsx @@ -17,7 +17,7 @@ import { } from '@mui/material' import { useCallback } from 'react' import { RPCResult } from '../types' -import { ellipsis, formatSpeedMiB, mapProcessStatus, roundMiB } from '../utils' +import { ellipsis, formatSpeedMiB, mapProcessStatus, formatSize } from '../utils' type Props = { download: RPCResult @@ -86,7 +86,7 @@ const DownloadCard: React.FC = ({ download, onStop, onCopy }) => { {!isCompleted() ? formatSpeedMiB(download.progress.speed) : ''} - {roundMiB(download.info.filesize_approx ?? 0)} + {formatSize(download.info.filesize_approx ?? 0)} diff --git a/frontend/src/components/DownloadsListView.tsx b/frontend/src/components/DownloadsListView.tsx index a4d070c..84b0602 100644 --- a/frontend/src/components/DownloadsListView.tsx +++ b/frontend/src/components/DownloadsListView.tsx @@ -14,7 +14,7 @@ import { import { useRecoilValue } from 'recoil' import { activeDownloadsState } from '../atoms/downloads' import { useRPC } from '../hooks/useRPC' -import { ellipsis, formatSpeedMiB, roundMiB } from "../utils" +import { ellipsis, formatSpeedMiB, formatSize } from "../utils" const DownloadsListView: React.FC = () => { @@ -74,7 +74,7 @@ const DownloadsListView: React.FC = () => { /> {formatSpeedMiB(download.progress.speed)} - {roundMiB(download.info.filesize_approx ?? 0)} + {formatSize(download.info.filesize_approx ?? 0)}