- Replace mobile placeholder with Expo Router app (tabs, playback, auth, library) - Move Convex backend to @otunes/convex for web and mobile reuse - Update web app imports and API routes to use shared package
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
"use client"
|
|
|
|
import { useQuery } from "convex/react"
|
|
|
|
import { AlbumCard } from "@/components/album-card"
|
|
import { LibraryLoading } from "@/components/library-loading"
|
|
import { PlaylistCard } from "@/components/playlist-card"
|
|
import { api } from "@otunes/convex/_generated/api"
|
|
import type { BrowseAlbum, PlaylistSummary } from "@otunes/convex/types"
|
|
|
|
function RecentlyPlayedCard({
|
|
item,
|
|
}: {
|
|
item: BrowseAlbum | PlaylistSummary
|
|
}) {
|
|
if ("owner" in item) {
|
|
return <PlaylistCard playlist={item} />
|
|
}
|
|
return <AlbumCard album={item} />
|
|
}
|
|
|
|
export default function Page() {
|
|
const recentlyPlayed = useQuery(api.library.browseRecentlyPlayed)
|
|
|
|
return (
|
|
<div className="flex h-svh flex-col">
|
|
<header className="flex items-center gap-2 border-b px-4 py-3">
|
|
<h1 className="text-lg font-semibold">Recently Played</h1>
|
|
</header>
|
|
|
|
{recentlyPlayed === undefined ? (
|
|
<LibraryLoading />
|
|
) : recentlyPlayed.length === 0 ? (
|
|
<div className="flex flex-1 items-center justify-center p-6 pb-28">
|
|
<p className="text-sm text-muted-foreground">
|
|
Your recently played albums and playlists will appear here.
|
|
</p>
|
|
</div>
|
|
) : (
|
|
<div className="flex-1 overflow-y-auto p-6 pb-28">
|
|
<div className="grid grid-cols-2 gap-x-6 gap-y-8 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
|
|
{recentlyPlayed.map((item) => (
|
|
<RecentlyPlayedCard key={item.id} item={item} />
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|