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}
>
<span className={styles.sizeOnDisk}>
{
formatBytes(sizeOnDisk || 0)
}
{formatBytes(sizeOnDisk)}
</span>
</InfoLabel>

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

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

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

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