import React, { Fragment } from 'react'; import { useTranslation } from 'react-i18next'; import { AudioLines, ChevronRight, Play, Square } from 'lucide-react'; import type { SubsonicSong } from '../../api/subsonicTypes'; import { usePlayerStore } from '../../store/playerStore'; import { usePreviewStore } from '../../store/previewStore'; import { useOrbitSongRowBehavior } from '../../hooks/useOrbitSongRowBehavior'; import { songToTrack } from '../../utils/songToTrack'; import { formatDuration } from '../../utils/artistDetailHelpers'; import ArtistSuggestionTrackCover from './ArtistSuggestionTrackCover'; interface Props { topSongs: SubsonicSong[]; marginTop: string; playTopSongWithContinuation: (startIndex: number) => Promise; } export default function ArtistDetailTopTracks({ topSongs, marginTop, playTopSongWithContinuation }: Props) { const { t } = useTranslation(); const currentTrack = usePlayerStore(s => s.currentTrack); const isPlaying = usePlayerStore(s => s.isPlaying); const openContextMenu = usePlayerStore(s => s.openContextMenu); const previewingId = usePreviewStore(s => s.previewingId); const previewAudioStarted = usePreviewStore(s => s.audioStarted); const { orbitActive, queueHint, addTrackToOrbit } = useOrbitSongRowBehavior(); return (

{t('artistDetail.topTracks')}

#
{t('artistDetail.trackTitle')}
{t('artistDetail.trackAlbum')}
{t('artistDetail.trackDuration')}
{topSongs.map((song, idx) => { const track = songToTrack(song); return (
{ if ((e.target as HTMLElement).closest('button, a, input')) return; if (orbitActive) { queueHint(); return; } playTopSongWithContinuation(idx); }} onDoubleClick={orbitActive ? e => { if ((e.target as HTMLElement).closest('button, a, input')) return; addTrackToOrbit(song.id); } : undefined} onContextMenu={(e) => { e.preventDefault(); openContextMenu(e.clientX, e.clientY, track, 'song'); }} >
{currentTrack?.id === song.id && isPlaying ? ( ) : ( {idx + 1} )}
{song.coverArt && ( )}
{song.title}
{song.album}
{formatDuration(song.duration)}
); })}
); }