Skip to content

Commit 76038a9

Browse files
committed
Fixes #18: Update HomePageComponent to trigger a re-render of the carousel when the user changes the timespan filter. This ensures the carousel always resets to the first page whenever the filter is changed
1 parent 2cd9588 commit 76038a9

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

web/src/modules/browse/components/HomePageComponent.tsx

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const HomePageComponent = () => {
2525
const { featuredSongsPage } = useFeaturedSongsProvider();
2626

2727
const { recentSongs, increasePageRecent, hasMore } = useRecentSongsProvider();
28-
28+
const { timespan } = useFeaturedSongsProvider();
2929
return (
3030
<>
3131
{/* Welcome banner/Hero */}
@@ -39,7 +39,9 @@ export const HomePageComponent = () => {
3939
<TimespanButtonGroup />
4040
</div>
4141
<div className='h-6' />
42+
4243
<Carousel
44+
key={timespan}
4345
opts={{
4446
align: 'start',
4547
loop: false,
@@ -60,6 +62,7 @@ export const HomePageComponent = () => {
6062
<CarouselNext />
6163
<CarouselDots />
6264
</Carousel>
65+
6366
<hr className='my-8 border-none bg-zinc-700 h-[3px]' />
6467
</>
6568
)}
@@ -88,31 +91,5 @@ export const HomePageComponent = () => {
8891
)}
8992
</div>
9093
</>
91-
// <InfiniteScroll
92-
// dataLength={recentSongs.length} //This is important field to render the next data
93-
// next={increasePageRecent}
94-
// hasMore={hasMore}
95-
// loader={
96-
// <div className='flex justify-center'>
97-
// <div className='spinner' />
98-
// </div>
99-
// }
100-
// endMessage={
101-
// <p style={{ textAlign: 'center' }}>
102-
// <b>Yay! You have seen it all</b>
103-
// </p>
104-
// }
105-
// >
106-
// <SongCardGroup data-test='recent-songs'>
107-
// {recentSongs.map((song, i) => (
108-
// <SongCard key={i} song={song} />
109-
// ))}
110-
// {isLoading &&
111-
// Array(4 - (recentSongs.length % 4) + 4)
112-
// .fill(null)
113-
// .map((_, i) => <SongCard key={i} song={null} />)}
114-
// </SongCardGroup>
115-
// </InfiniteScroll>
116-
//</>
11794
);
11895
};

0 commit comments

Comments
 (0)