add refresh button to album / artist carousels

This commit is contained in:
jeffvli
2025-12-03 18:05:15 -08:00
parent 9d498d4ca2
commit a47f94ebb2
3 changed files with 61 additions and 25 deletions
@@ -34,6 +34,7 @@ const BaseAlbumInfiniteCarousel = (props: AlbumCarouselProps) => {
data: albums,
fetchNextPage,
hasNextPage,
refetch,
} = useAlbumListInfinite(sortBy, sortOrder, 20, additionalQuery);
const controls = useDefaultItemListControls();
@@ -65,6 +66,10 @@ const BaseAlbumInfiniteCarousel = (props: AlbumCarouselProps) => {
const handlePrevPage = useCallback(() => {}, []);
const handleRefresh = useCallback(() => {
refetch();
}, [refetch]);
const firstPageItems = excludeIds
? albums.pages[0]?.items.filter((album) => !excludeIds.includes(album.id)) || []
: albums.pages[0]?.items || [];
@@ -80,6 +85,7 @@ const BaseAlbumInfiniteCarousel = (props: AlbumCarouselProps) => {
loadNextPage={fetchNextPage}
onNextPage={handleNextPage}
onPrevPage={handlePrevPage}
onRefresh={handleRefresh}
rowCount={rowCount}
title={title}
/>
@@ -34,6 +34,7 @@ export const BaseAlbumArtistInfiniteCarousel = (props: AlbumArtistCarouselProps)
data: albumArtists,
fetchNextPage,
hasNextPage,
refetch,
} = useAlbumArtistListInfinite(sortBy, sortOrder, 20, additionalQuery);
const controls = useDefaultItemListControls();
@@ -65,6 +66,10 @@ export const BaseAlbumArtistInfiniteCarousel = (props: AlbumArtistCarouselProps)
const handlePrevPage = useCallback(() => {}, []);
const handleRefresh = useCallback(() => {
refetch();
}, [refetch]);
const firstPageItems = excludeIds
? albumArtists.pages[0]?.items.filter(
(albumArtist) => !excludeIds.includes(albumArtist.id),
@@ -82,6 +87,7 @@ export const BaseAlbumArtistInfiniteCarousel = (props: AlbumArtistCarouselProps)
loadNextPage={fetchNextPage}
onNextPage={handleNextPage}
onPrevPage={handlePrevPage}
onRefresh={handleRefresh}
rowCount={rowCount}
title={title}
/>