refactor: Remove duplicate code for getting poster thumbnail URL

This commit is contained in:
Peifan Li
2025-12-28 14:24:45 -05:00
parent 05df7e2512
commit 630ecd2ffb

View File

@@ -118,6 +118,15 @@ const VideoPlayer: React.FC = () => {
// Get cloud storage URLs
const videoUrl = useCloudStorageUrl(video?.videoPath, 'video');
// Get thumbnail URL for poster
// Only load thumbnail from cloud if the video itself is in cloud storage
const isVideoInCloud = video?.videoPath?.startsWith('cloud:') ?? false;
const thumbnailPathForCloud = isVideoInCloud ? video?.thumbnailPath : null;
const posterUrl = useCloudStorageUrl(thumbnailPathForCloud, 'thumbnail');
const localPosterUrl = !isVideoInCloud && video?.thumbnailPath
? `${import.meta.env.VITE_BACKEND_URL ?? 'http://localhost:5551'}${video.thumbnailPath}`
: undefined;
// Fetch comments
const { data: comments = [], isLoading: loadingComments } = useQuery({
queryKey: ['comments', id],
@@ -618,15 +627,6 @@ const VideoPlayer: React.FC = () => {
}
};
// Get thumbnail URL for poster
// Only load thumbnail from cloud if the video itself is in cloud storage
const isVideoInCloud = video?.videoPath?.startsWith('cloud:') ?? false;
const thumbnailPathForCloud = isVideoInCloud ? video?.thumbnailPath : null;
const posterUrl = useCloudStorageUrl(thumbnailPathForCloud, 'thumbnail');
const localPosterUrl = !isVideoInCloud && video?.thumbnailPath
? `${import.meta.env.VITE_BACKEND_URL ?? 'http://localhost:5551'}${video.thumbnailPath}`
: undefined;
return (
<Container maxWidth={false} disableGutters sx={{ py: { xs: 0, md: 4 }, px: { xs: 0, md: 2 } }}>
<Grid container spacing={{ xs: 0, md: 4 }}>