mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-30 01:22:56 +01:00
# Add download size to offline media downloads
- Added getDownloadSize helper function to display media size in MB or GB when appropriate
This commit is contained in:
31
components/downloads/DownloadSize.tsx
Normal file
31
components/downloads/DownloadSize.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
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>
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user