Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Refresh Indicator in experimental layout #5724

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/cardbuilder/Card/CardImageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ const CardImageContainer: FC<CardImageContainerProps> = ({
indicator.getPlayedIndicator()}

{(item.Type === BaseItemKind.CollectionFolder
|| item.CollectionType)
&& item.RefreshProgress && (
|| item.CollectionType) && (
<RefreshIndicator item={item} />
)}
</Box>
Expand Down
25 changes: 17 additions & 8 deletions src/elements/emby-itemrefreshindicator/RefreshIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand All @@ -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>
);
};
Expand Down
Loading