Convert formatBytes to TypeScript

Closes #10272
pull/10296/head
Bogdan 3 months ago
parent abc7efabea
commit 6c456e57d8

@ -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>

@ -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),
}; };
} }

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

@ -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;

@ -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,
})}`; })}`;
} }
Loading…
Cancel
Save