30 lines
827 B
TypeScript
30 lines
827 B
TypeScript
import { MediaGridList } from "@/components/media-cards"
|
|
import { MediaGridSkeleton } from "@/components/skeletons"
|
|
import { contentBottomInset } from "@/components/player"
|
|
import { useCachedPaginatedQuery } from "@/hooks/use-cached-query"
|
|
import { api } from "@otunes/convex/_generated/api"
|
|
|
|
const PAGE_SIZE = 50
|
|
|
|
export default function RecentlyPlayedScreen() {
|
|
const { results, status, loadMore, isCached } = useCachedPaginatedQuery(
|
|
api.library.browseRecentlyPlayedPaginated,
|
|
{},
|
|
{ initialNumItems: PAGE_SIZE }
|
|
)
|
|
|
|
if (status === "LoadingFirstPage" && !isCached) {
|
|
return <MediaGridSkeleton />
|
|
}
|
|
|
|
return (
|
|
<MediaGridList
|
|
content={results}
|
|
paddingBottom={contentBottomInset}
|
|
onEndReached={() => {
|
|
if (status === "CanLoadMore") loadMore(PAGE_SIZE)
|
|
}}
|
|
/>
|
|
)
|
|
}
|