import { useTranslation } from 'react-i18next'; import { Play, Radio, Heart, ChevronRight, User, Disc3, ListMusic, Info, Sparkles, Star, Trash2, Share2 } from 'lucide-react'; import { star, unstar } from '../../api/subsonicStarRating'; import { lastfmLoveTrack, lastfmUnloveTrack } from '../../api/lastfm'; import type { Track } from '../../store/playerStoreTypes'; import { useAuthStore } from '../../store/authStore'; import LastfmIcon from '../LastfmIcon'; import StarRating from '../StarRating'; import { AddToPlaylistSubmenu } from './AddToPlaylistSubmenu'; import type { ContextMenuItemsProps } from './contextMenuItemTypes'; export default function QueueItemContextItems(props: ContextMenuItemsProps) { const { type, item, queueIndex, playlistId, playlistSongIndex, shareKindOverride, playTrack, playNext, enqueue, removeTrack, queue, currentTrack, closeContextMenu, starredOverrides, setStarredOverride, lastfmLovedCache, setLastfmLovedForSong, openSongInfo, userRatingOverrides, setKeyboardRating, keyboardRating, playlistSubmenuOpen, setPlaylistSubmenuOpen, cancelPlaylistSubmenuCloseTimer, onPlaylistSubmenuTriggerMouseLeave, playlistSongIds, setPlaylistSongIds, orbitRole, entityRatingSupport, audiomuseNavidromeEnabled, applySongRating, applyAlbumRating, applyArtistRating, handleAction, startRadio, startInstantMix, downloadAlbum, copyShareLink, isStarred, navigateLibrary, } = props; const { t } = useTranslation(); const auth = useAuthStore(); return ( <> {type === 'queue-item' && (() => { const song = item as Track; return ( <>
handleAction(() => playTrack(song, queue, undefined, undefined, queueIndex))}> {t('contextMenu.playNow')}
handleAction(() => { if (queueIndex !== undefined) removeTrack(queueIndex); })}> {t('contextMenu.removeFromQueue')}
{ cancelPlaylistSubmenuCloseTimer(); setPlaylistSongIds([song.id]); setPlaylistSubmenuOpen(true); }} onMouseLeave={onPlaylistSubmenuTriggerMouseLeave} > {t('contextMenu.addToPlaylist')} {playlistSubmenuOpen && playlistSongIds[0] === song.id && ( { setPlaylistSubmenuOpen(false); closeContextMenu(); }} /> )}
{song.albumId && (
handleAction(() => navigateLibrary(`/album/${song.albumId}`))}> {t('contextMenu.openAlbum')}
)} {song.artistId && (
handleAction(() => navigateLibrary(`/artist/${song.artistId}`))}> {t('contextMenu.goToArtist')}
)}
handleAction(() => startRadio(song.artistId ?? song.artist, song.artist, song))}> {t('contextMenu.startRadio')}
{audiomuseNavidromeEnabled && (
handleAction(() => startInstantMix(song))}> {t('contextMenu.instantMix')}
)}
handleAction(() => { const starred = isStarred(song.id, song.starred); setStarredOverride(song.id, !starred); return starred ? unstar(song.id, 'song') : star(song.id, 'song'); })}> {isStarred(song.id, song.starred) ? t('contextMenu.unfavorite') : t('contextMenu.favorite')}
{auth.lastfmSessionKey && (() => { const loveKey = `${song.title}::${song.artist}`; const loved = lastfmLovedCache[loveKey] ?? false; return (
handleAction(() => { const newLoved = !loved; setLastfmLovedForSong(song.title, song.artist, newLoved); if (newLoved) lastfmLoveTrack(song, auth.lastfmSessionKey); else lastfmUnloveTrack(song, auth.lastfmSessionKey); })}> {loved ? t('contextMenu.lfmUnlove') : t('contextMenu.lfmLove')}
); })()}
e.stopPropagation()} > { setKeyboardRating({ kind: 'song', id: song.id, value: r }); applySongRating(song.id, r); }} ariaLabel={t('albumDetail.ratingLabel')} />
handleAction(() => copyShareLink('track', song.id))}> {t('contextMenu.shareLink')}
handleAction(() => openSongInfo(song.id))}> {t('contextMenu.songInfo')}
); })()} ); }