1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-19 17:32:38 +01:00

Convert formatBytes to TypeScript

Closes #10272
This commit is contained in:
Bogdan 2024-08-14 18:48:49 +03:00
parent abc7efabea
commit 6c456e57d8
5 changed files with 8 additions and 8 deletions

View File

@ -568,9 +568,7 @@ class MovieDetails extends Component {
size={sizes.LARGE} size={sizes.LARGE}
> >
<span className={styles.sizeOnDisk}> <span className={styles.sizeOnDisk}>
{ {formatBytes(sizeOnDisk)}
formatBytes(sizeOnDisk || 0)
}
</span> </span>
</InfoLabel> </InfoLabel>

View File

@ -134,10 +134,12 @@ function getInfoRowProps(
} }
if (name === 'sizeOnDisk') { if (name === 'sizeOnDisk') {
const { sizeOnDisk = 0 } = props;
return { return {
title: 'Size on Disk', title: 'Size on Disk',
iconName: icons.DRIVE, iconName: icons.DRIVE,
label: formatBytes(props.sizeOnDisk), label: formatBytes(sizeOnDisk),
}; };
} }

View File

@ -58,7 +58,7 @@ function MovieIndexPosterInfo(props: MovieIndexPosterInfoProps) {
certification, certification,
originalTitle, originalTitle,
originalLanguage, originalLanguage,
sizeOnDisk, sizeOnDisk = 0,
tags = [], tags = [],
sortKey, sortKey,
showRelativeDates, showRelativeDates,

View File

@ -21,7 +21,7 @@ interface RootFolderRowProps {
} }
function RootFolderRow(props: RootFolderRowProps) { function RootFolderRow(props: RootFolderRowProps) {
const { id, path, accessible, freeSpace, unmappedFolders = [] } = props; const { id, path, accessible, freeSpace = 0, unmappedFolders = [] } = props;
const isUnavailable = !accessible; const isUnavailable = !accessible;

View File

@ -1,6 +1,6 @@
import { filesize } from 'filesize'; import { filesize } from 'filesize';
function formatBytes(input) { function formatBytes(input: string | number) {
const size = Number(input); const size = Number(input);
if (isNaN(size)) { if (isNaN(size)) {
@ -9,7 +9,7 @@ function formatBytes(input) {
return `${filesize(size, { return `${filesize(size, {
base: 2, base: 2,
round: 1 round: 1,
})}`; })}`;
} }