-
+ {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 }) {