1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix Refresh Indicator

This commit is contained in:
grafixeyehero 2024-06-22 19:04:49 +03:00
parent 72f5d1c73b
commit 4562f34995
2 changed files with 18 additions and 10 deletions

View file

@ -54,8 +54,7 @@ const CardImageContainer: FC<CardImageContainerProps> = ({
indicator.getPlayedIndicator()}
{(item.Type === BaseItemKind.CollectionFolder
|| item.CollectionType)
&& item.RefreshProgress && (
|| item.CollectionType) && (
<RefreshIndicator item={item} />
)}
</Box>

View file

@ -49,11 +49,20 @@ interface RefreshIndicatorProps {
}
const RefreshIndicator: FC<RefreshIndicatorProps> = ({ item, className }) => {
const [showProgressBar, setShowProgressBar] = useState(!!item.RefreshProgress);
const [progress, setProgress] = useState(item.RefreshProgress || 0);
const onRefreshProgress = useCallback((_e: Event, _apiClient: ApiClient, info: { ItemId: string | null | undefined; Progress: string; }) => {
if (info.ItemId === item?.Id) {
setProgress(parseFloat(info.Progress));
const pct = parseFloat(info.Progress);
if (pct && pct < 100) {
setShowProgressBar(true);
} else {
setShowProgressBar(false);
}
setProgress(pct);
}
}, [item?.Id]);
@ -77,15 +86,15 @@ const RefreshIndicator: FC<RefreshIndicatorProps> = ({ item, className }) => {
};
}, [bindEvents, item.Id, unbindEvents]);
const progressringClass = classNames(
'progressring',
className,
{ 'hide': !progress || progress >= 100 }
);
const progressringClass = classNames('progressring', className);
return (
<div className={progressringClass}>
<CircularProgressWithLabel value={Math.floor(progress)} />
<div>
{showProgressBar && (
<div className={progressringClass}>
<CircularProgressWithLabel value={Math.floor(progress)} />
</div>
)}
</div>
);
};