From ca82ea2008a29daf0cdef741dee0960b2f54343b Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Fri, 20 Nov 2026 00:21:23 -0500 Subject: [PATCH] feat(web): right click menu for queue history and current song Co-Authored-By: Claude Opus 5.5 --- apps/web/components/queue-panel.tsx | 129 +++++++++++++++++++--------- 1 file changed, 90 insertions(+), 39 deletions(-) diff --git a/apps/web/components/queue-panel.tsx b/apps/web/components/queue-panel.tsx index b318ffa..6f2cf9e 100644 --- a/apps/web/components/queue-panel.tsx +++ b/apps/web/components/queue-panel.tsx @@ -3,12 +3,16 @@ import * as React from "react" import { useFavorites } from "@/components/favorites-provider" -import type { MediaContextAction } from "@/components/media-context-menu" +import { + MediaContextMenuArea, + type MediaContextAction, +} from "@/components/media-context-menu" import { PlaybackSongMeta } from "@/components/playback-song-meta" import { usePlayback } from "@/components/playback-provider" import { TrackCover, TrackRow } from "@/components/track-row" import { Skeleton } from "@/components/ui/skeleton" import { Spinner } from "@/components/ui/spinner" +import { useSongDownloadState } from "@/hooks/use-downloads" import { useMediaActions } from "@/hooks/use-media-actions" import { useTrackSelection } from "@/hooks/use-track-selection" import type { Id } from "@otunes/convex/_generated/dataModel" @@ -50,6 +54,51 @@ function toSelectableQueue( }) } +/** + * Opens the song's right-click menu over `children`, for the queue rows that + * stand alone (history and the current song) rather than in the selection. + */ +function SongMenuArea({ + song, + children, +}: { + song: BrowseSong + children: React.ReactElement +}) { + const { isSongFavorite, toggleSongFavorite } = useFavorites() + const { runSongsAction } = useMediaActions() + const downloaded = useSongDownloadState(song.id) === "here" + + function handleAction(action: MediaContextAction) { + if (action === "favorite") { + void toggleSongFavorite(song.id) + return + } + runSongsAction(action, [song.id], song.artist.id) + } + + return ( + {}, + onAction: handleAction, + favorited: isSongFavorite(song.id), + downloaded, + navigation: { + artist: { id: song.artist.id }, + album: { id: song.album.id }, + }, + share: { type: "song", albumId: song.album.id, songId: song.id }, + }} + > + {children} + + ) +} + /** A played song; clicking it plays it again from that point in history. */ function HistorySongRow({ song, @@ -65,25 +114,27 @@ function HistorySongRow({ } return ( -
  • onPlay(historyIndex)} - onKeyDown={(event) => { - if (event.key === "Enter" || event.key === " ") { - event.preventDefault() - onPlay(historyIndex) - } - }} - > - - -
  • + +
  • onPlay(historyIndex)} + onKeyDown={(event) => { + if (event.key === "Enter" || event.key === " ") { + event.preventDefault() + onPlay(historyIndex) + } + }} + > + + +
  • +
    ) } @@ -354,25 +405,25 @@ export function QueuePanel() { {/* Fills the viewport so the current song can always scroll to the top. */}
    - {currentQueueSongId ? ( -
    - {currentSong ? ( - <> - - - - ) : ( - - )} + {currentSong ? ( + +
    + + +
    +
    + ) : currentQueueSongId ? ( +
    +
    ) : null}