mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
- Added getDownloadSize helper function to display media size in MB or GB when appropriate
31 lines
773 B
TypeScript
31 lines
773 B
TypeScript
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
|
|
import React, {useEffect, useMemo, useState} from "react";
|
|
import {Text} from "@/components/common/Text";
|
|
import useDownloadHelper from "@/utils/download";
|
|
|
|
interface DownloadSizeProps {
|
|
items: BaseItemDto[];
|
|
}
|
|
|
|
export const DownloadSize: React.FC<DownloadSizeProps> = ({ items }) => {
|
|
const { getDownloadSize } = useDownloadHelper();
|
|
const [size, setSize] = useState<string | undefined>();
|
|
|
|
useEffect(() => {
|
|
getDownloadSize(...items).then(setSize)
|
|
},
|
|
[items]
|
|
);
|
|
|
|
const sizeText = useMemo(() => {
|
|
if (!size)
|
|
return "reading size..."
|
|
return size
|
|
}, [size])
|
|
|
|
return (
|
|
<>
|
|
<Text className="text-xs text-neutral-500">{sizeText}</Text>
|
|
</>
|
|
);
|
|
}; |