diff --git a/apps/web/components/album-card.tsx b/apps/web/components/album-card.tsx index b17a7a6..076ac12 100644 --- a/apps/web/components/album-card.tsx +++ b/apps/web/components/album-card.tsx @@ -13,7 +13,7 @@ import { MediaContextMenuItems, type MediaContextAction, } from "@/components/media-context-menu" -import { usePlayback } from "@/components/playback-provider" +import { usePlaybackActions } from "@/components/playback-provider" import { useQueueMediaActions } from "@/hooks/use-queue-media-actions" import { api } from "@otunes/convex/_generated/api" import { Button } from "@/components/ui/button" @@ -48,7 +48,7 @@ export function AlbumCard({ album }: { album: BrowseAlbum }) { const cacheScope = useCacheScope() const { openAddAlbumToPlaylist } = useAddToPlaylist() const { isAlbumFavorite, toggleAlbumFavorite } = useFavorites() - const { playAlbum } = usePlayback() + const { playAlbum } = usePlaybackActions() const { runQueueAction, createStation } = useQueueMediaActions() const [menuOpen, setMenuOpen] = React.useState(false) const [hovered, setHovered] = React.useState(false) diff --git a/apps/web/components/album-view.tsx b/apps/web/components/album-view.tsx index 5fc401c..e18b273 100644 --- a/apps/web/components/album-view.tsx +++ b/apps/web/components/album-view.tsx @@ -11,7 +11,10 @@ import { MediaCollectionFooter } from "@/components/media-collection-footer" import { FavoriteMediaButton } from "@/components/favorite-media-button" import { useFavorites } from "@/components/favorites-provider" -import { usePlayback } from "@/components/playback-provider" +import { + useCurrentSongId, + usePlaybackActions, +} from "@/components/playback-provider" import { copyAlbumLink } from "@/lib/media-links" import { @@ -105,8 +108,8 @@ export function AlbumView({ toggleSongFavorite, toggleAlbumFavorite, } = useFavorites() - const { currentSong, playFromSong, playAlbum, playAlbumShuffled } = - usePlayback() + const currentSongId = useCurrentSongId() + const { playFromSong, playAlbum, playAlbumShuffled } = usePlaybackActions() const { runSongsAction } = useMediaActions() const albumSongIds = React.useMemo( () => album.tracks.map((track) => track.id as Id<"songs">), @@ -366,7 +369,7 @@ export function AlbumView({ isFavorite={isSongFavorite(track.id)} selectedCount={selectedCount} selectionStationArtistId={album.artist.id} - isNowPlaying={currentSong?.id === track.id} + isNowPlaying={currentSongId === track.id} onPointerDown={handlePointerDown} onSelect={handleRowSelect} onPlay={handleRowPlay} diff --git a/apps/web/components/artist-view.tsx b/apps/web/components/artist-view.tsx index 5bab21e..5ab9e1e 100644 --- a/apps/web/components/artist-view.tsx +++ b/apps/web/components/artist-view.tsx @@ -6,7 +6,7 @@ import Image from "next/image" import { Play, Shuffle } from "lucide-react" import { useFavorites } from "@/components/favorites-provider" -import { usePlayback } from "@/components/playback-provider" +import { usePlaybackActions } from "@/components/playback-provider" import { useMediaActions } from "@/hooks/use-media-actions" import { AlbumCard } from "@/components/album-card" import { FavoriteMediaButton } from "@/components/favorite-media-button" @@ -26,7 +26,7 @@ export function ArtistView({ albums: BrowseAlbum[] }) { const { isArtistFavorite, toggleArtistFavorite } = useFavorites() - const { playArtist, playArtistShuffled } = usePlayback() + const { playArtist, playArtistShuffled } = usePlaybackActions() const { runArtistAction } = useMediaActions() return ( diff --git a/apps/web/components/artists-view.tsx b/apps/web/components/artists-view.tsx index 48b3d8a..f10b361 100644 --- a/apps/web/components/artists-view.tsx +++ b/apps/web/components/artists-view.tsx @@ -11,8 +11,10 @@ import { useFavorites } from "@/components/favorites-provider" import { MediaContextMenu, type MediaContextAction, + MediaContextMenuArea, + type MediaContextMenuProps, } from "@/components/media-context-menu" -import { usePlayback } from "@/components/playback-provider" +import { usePlaybackActions } from "@/components/playback-provider" import { useMediaActions } from "@/hooks/use-media-actions" import { Button } from "@/components/ui/button" import { ScrollArea } from "@/components/ui/scroll-area" @@ -50,36 +52,42 @@ function ArtistListItem({ onSelect: () => void onMediaAction: (action: MediaContextAction) => void }) { + const menu: MediaContextMenuProps = { + label: `More options for ${artist.name}`, + selectedCount: albumCount, + inSelectionRange: isSelected, + onOpenMenu: () => {}, + onAction: onMediaAction, + favorited: isFavorite, + share: { type: "artist", artistId: artist.id }, + } + return ( -
{normalizedQuery diff --git a/apps/web/components/search-song-item.tsx b/apps/web/components/search-song-item.tsx index 136d8ee..b4bfe05 100644 --- a/apps/web/components/search-song-item.tsx +++ b/apps/web/components/search-song-item.tsx @@ -8,6 +8,8 @@ import { useQueueMediaActions } from "@/hooks/use-queue-media-actions" import { MediaContextMenu, type MediaContextAction, + MediaContextMenuArea, + type MediaContextMenuProps, } from "@/components/media-context-menu" import type { Id } from "@otunes/convex/_generated/dataModel" import type { BrowseSong } from "@otunes/convex/types" @@ -38,52 +40,57 @@ export function SearchSongItem({ song }: { song: BrowseSong }) { } } + const menu: MediaContextMenuProps = { + label: `More options for ${song.title}`, + stationArtistId: song.artist.id, + selectedCount: 1, + onOpenMenu: () => {}, + onAction: handleAction, + favorited: isSongFavorite(song.id), + navigation: { + artist: { id: song.artist.id }, + album: { id: song.album.id }, + }, + share: { + type: "song", + albumId: song.album.id, + songId: song.id, + }, + triggerClassName: + "size-8 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100", + triggerVariant: "ghost", + } + return ( -
{song.title}
- +{song.artist.name}
+{song.title}
+ + +{song.artist.name}
+ +