31 lines
765 B
TypeScript
31 lines
765 B
TypeScript
import { usePaginatedQuery } from "convex/react"
|
|
|
|
import { MediaGridList } from "@/components/media-cards"
|
|
import { LoadingView } from "@/components/ui/primitives"
|
|
import { contentBottomInset } from "@/components/player"
|
|
import { api } from "@otunes/convex/_generated/api"
|
|
|
|
const PAGE_SIZE = 50
|
|
|
|
export default function RecentlyPlayedScreen() {
|
|
const { results, status, loadMore } = usePaginatedQuery(
|
|
api.library.browseRecentlyPlayedPaginated,
|
|
{},
|
|
{ initialNumItems: PAGE_SIZE }
|
|
)
|
|
|
|
if (results === undefined) {
|
|
return <LoadingView />
|
|
}
|
|
|
|
return (
|
|
<MediaGridList
|
|
content={results}
|
|
paddingBottom={contentBottomInset}
|
|
onEndReached={() => {
|
|
if (status === "CanLoadMore") loadMore(PAGE_SIZE)
|
|
}}
|
|
/>
|
|
)
|
|
}
|