diff --git a/app/(app)/album/[id]/page.tsx b/app/(app)/album/[id]/page.tsx index 23ff8a7..aad178c 100644 --- a/app/(app)/album/[id]/page.tsx +++ b/app/(app)/album/[id]/page.tsx @@ -7,7 +7,6 @@ import { AlbumView } from "@/components/album-view" import { LibraryLoading } from "@/components/library-loading" import { api } from "@/convex/_generated/api" import type { Id } from "@/convex/_generated/dataModel" -import type { BrowseAlbumDetail } from "@/convex/library" export default function Page() { const { id } = useParams<{ id: string }>() @@ -33,5 +32,13 @@ export default function Page() { ) } - return + return ( + <> + {`${album.title} - oTunes`} + + + + + + ) } diff --git a/app/(app)/artist/[id]/page.tsx b/app/(app)/artist/[id]/page.tsx index 6afbe2b..ef5a4df 100644 --- a/app/(app)/artist/[id]/page.tsx +++ b/app/(app)/artist/[id]/page.tsx @@ -33,11 +33,17 @@ export default function Page() { } return ( - + <> + {`${data.artist.name} - oTunes`} + + {/**/} + + + ) } diff --git a/app/(app)/page.tsx b/app/(app)/page.tsx index d77dbd7..30c1145 100644 --- a/app/(app)/page.tsx +++ b/app/(app)/page.tsx @@ -8,7 +8,7 @@ import { api } from "@/convex/_generated/api" export default function Page() { const recentlyAdded = useQuery(api.library.browseRecentlyAdded) - const recentlyPlayed = useQuery(api.library.browseAlbums) + const recentlyPlayed = useQuery(api.library.browseRecentlyPlayed) if (recentlyAdded === undefined || recentlyPlayed === undefined) { return ( @@ -29,11 +29,13 @@ export default function Page() {
- + {recentlyPlayed.length > 0 ? ( + + ) : null} + return ( + <> + {`${playlist.title} - oTunes`} + + + + + + ) } diff --git a/app/(app)/recently-played/page.tsx b/app/(app)/recently-played/page.tsx index f71316b..380be14 100644 --- a/app/(app)/recently-played/page.tsx +++ b/app/(app)/recently-played/page.tsx @@ -4,10 +4,23 @@ 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 "@/convex/_generated/api" +import type { BrowseAlbum, PlaylistSummary } from "@/convex/library" + +function RecentlyPlayedCard({ + item, +}: { + item: BrowseAlbum | PlaylistSummary +}) { + if ("owner" in item) { + return + } + return +} export default function Page() { - const albums = useQuery(api.library.browseAlbums) + const recentlyPlayed = useQuery(api.library.browseRecentlyPlayed) return (
@@ -15,13 +28,19 @@ export default function Page() {

Recently Played

- {albums === undefined ? ( + {recentlyPlayed === undefined ? ( + ) : recentlyPlayed.length === 0 ? ( +
+

+ Your recently played albums and playlists will appear here. +

+
) : (
- {albums.map((album) => ( - + {recentlyPlayed.map((item) => ( + ))}
diff --git a/components/artists-view.tsx b/components/artists-view.tsx index 00cb246..9713ec7 100644 --- a/components/artists-view.tsx +++ b/components/artists-view.tsx @@ -69,7 +69,9 @@ function ArtistListItem({ )} > - {artist.name} + + {artist.name} + { - if ( - artistId && - sortedArtists.some((artist) => artist.id === artistId) - ) { + if (artistId && sortedArtists.some((artist) => artist.id === artistId)) { return artistId } return sortedArtists[0]?.id ?? "" @@ -151,98 +150,119 @@ export function ArtistsView({ } return ( -
- -
- {sortedArtists.map((artist) => ( - router.push(`/library/artists/${artist.id}`)} - onMediaAction={(action) => - void handleMediaAction(artist.id, action) - } - /> - ))} -
-
+ <> + {`${selectedArtist && artistId ? `${selectedArtist.name} - oTunes` : "oTunes"}`} + + + +
+ +
+ {sortedArtists.map((artist) => ( + router.push(`/library/artists/${artist.id}`)} + onMediaAction={(action) => + void handleMediaAction(artist.id, action) + } + /> + ))} +
+
- - {selectedArtist ? ( -
-
- - {selectedArtist.name} - - + + {selectedArtist ? ( +
+
+ + + {selectedArtist.name} + + + -
- - - - void toggleArtistFavorite(selectedArtist.id as Id<"artists">) - } - favoritedLabel={`Remove ${selectedArtist.name} from favorites`} - unfavoritedLabel={`Favorite ${selectedArtist.name}`} - /> - {}} - onAction={(action) => - void handleMediaAction(selectedArtist.id, action) - } - favorited={isArtistFavorite(selectedArtist.id)} - trackRowTrigger={false} - triggerVariant="secondary" - triggerClassName="rounded-full" - /> +
+ + + + void toggleArtistFavorite( + selectedArtist.id as Id<"artists"> + ) + } + favoritedLabel={`Remove ${selectedArtist.name} from favorites`} + unfavoritedLabel={`Favorite ${selectedArtist.name}`} + /> + {}} + onAction={(action) => + void handleMediaAction(selectedArtist.id, action) + } + favorited={isArtistFavorite(selectedArtist.id)} + trackRowTrigger={false} + triggerVariant="secondary" + triggerClassName="rounded-full" + /> +
+
+ +
+ {artistAlbums.length > 0 ? ( +
+ {artistAlbums.map((album) => ( + + ))} +
+ ) : ( +

+ No albums for this artist. +

+ )}
- -
- {artistAlbums.length > 0 ? ( -
- {artistAlbums.map((album) => ( - - ))} -
- ) : ( -

- No albums for this artist. -

- )} -
-
- ) : null} -
-
+ ) : null} + +
+ ) } diff --git a/components/playback-provider.tsx b/components/playback-provider.tsx index 8e07d40..0578281 100644 --- a/components/playback-provider.tsx +++ b/components/playback-provider.tsx @@ -971,9 +971,10 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { const songIds = await convex.query(api.playlists.getPlaylistSongIds, { playlistId, }) - await playInOrder(songIds) + await playInOrderMutation({ songIds, playlistId }) + setIsPlaying(true) }, - [convex, playInOrder] + [convex, playInOrderMutation] ) const playPlaylistShuffled = useCallback( @@ -981,9 +982,10 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { const songIds = await convex.query(api.playlists.getPlaylistSongIds, { playlistId, }) - await playShuffled(songIds) + await playShuffledMutation({ songIds, playlistId }) + setIsPlaying(true) }, - [convex, playShuffled] + [convex, playShuffledMutation] ) const toggleQueueOpen = useCallback(() => { diff --git a/components/playlist-view.tsx b/components/playlist-view.tsx index d0c8bc8..782f60a 100644 --- a/components/playlist-view.tsx +++ b/components/playlist-view.tsx @@ -291,8 +291,8 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) { } = useFavorites() const { currentSong, - playInOrder, - playShuffled, + playPlaylist, + playPlaylistShuffled, playFromSong, } = usePlayback() const { runQueueAction } = useQueueMediaActions() @@ -563,7 +563,9 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) { size="icon" className="rounded-full" aria-label="Shuffle playlist" - onClick={() => void playShuffled(playlistSongIds)} + onClick={() => + void playPlaylistShuffled(playlist.id as Id<"playlists">) + } disabled={playlistSongIds.length === 0} > @@ -571,7 +573,9 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {