chore: small fixes

This commit is contained in:
Fredrik Burmester
2024-10-05 19:19:34 +02:00
parent 0080874213
commit 81aafa26d4
8 changed files with 47 additions and 32 deletions

View File

@@ -48,9 +48,18 @@ const ContinueWatchingPoster: React.FC<ContinueWatchingPosterProps> = ({
}
}, [item]);
const [progress, setProgress] = useState(
item.UserData?.PlayedPercentage || 0
);
const progress = useMemo(() => {
if (item.Type === "Program") {
const startDate = new Date(item.StartDate || "");
const endDate = new Date(item.EndDate || "");
const now = new Date();
const total = endDate.getTime() - startDate.getTime();
const elapsed = now.getTime() - startDate.getTime();
return (elapsed / total) * 100;
} else {
return item.UserData?.PlayedPercentage || 0;
}
}, []);
if (!url)
return (