Skip to content

Commit db02d81

Browse files
committed
fix(home): ensure that videos skeletons are correctly displayed
1 parent 31cb853 commit db02d81

File tree

1 file changed

+10
-2
lines changed
  • src/ui/components/pages/Home/ChannelRenderer/ChannelVideos

1 file changed

+10
-2
lines changed

src/ui/components/pages/Home/ChannelRenderer/ChannelVideos/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useEffect, useRef } from 'react';
22
import { Box, Grid } from '@mui/material';
33
import { HomeView, Video } from 'types';
44
import VideoCard from './VideoCard';
@@ -29,8 +29,16 @@ function ChannelVideos(props: ChannelVideosProps) {
2929
onVideoPlay,
3030
onLoadMore,
3131
} = props;
32+
const showSkeletons = useRef(true);
3233
const skeletonNumber = Math.min(maxResults - videos.length, itemsPerRow);
3334

35+
useEffect(() => {
36+
if (!isLoading) {
37+
showSkeletons.current = hasMore ?? true;
38+
}
39+
// eslint-disable-next-line react-hooks/exhaustive-deps
40+
}, [isLoading]);
41+
3442
return (
3543
<Box sx={{ display: 'flex', pl: 6 }}>
3644
<Grid container spacing={config.gridSpacing} columns={config.gridColumns}>
@@ -39,7 +47,7 @@ function ChannelVideos(props: ChannelVideosProps) {
3947
<VideoCard video={video} view={view} onVideoPlay={onVideoPlay} />
4048
</GridItem>
4149
))}
42-
{isLoading && hasMore && skeletonNumber > 0
50+
{isLoading && showSkeletons.current && skeletonNumber > 0
4351
? Array.from(new Array(skeletonNumber)).map((_, index: number) => (
4452
<GridItem key={index}>
4553
<VideoSkeleton />

0 commit comments

Comments
 (0)