import { type MutableRefObject } from 'react'; import { useTranslation } from 'react-i18next'; import { AlbumRow } from '@/features/album'; import { ArtistRow } from '@/features/artist'; import PagedSongList from '@/features/search/components/PagedSongList'; import { LOSSLESS_MODE_QUERY } from '@/lib/library/losslessMode'; import type { Results, SearchOpts } from '@/features/search/searchBrowseTypes'; interface AdvancedSearchResultsProps { showAdvancedPanel: boolean; hasSearched: boolean; loading: boolean; basicSearchMode: boolean; query: string; filteredResults: Results | null; activeSearch: SearchOpts | null; genreNote: boolean; songsHasMore: boolean; loadingMoreSongs: boolean; loadMoreSongs: () => void; artistRowScrollLeftRestoreRef: MutableRefObject; artistRowScrollLeftRef: MutableRefObject; albumRowScrollLeftRestoreRef: MutableRefObject; albumRowScrollLeftRef: MutableRefObject; } /** Results area for the search shell: empty/loading/no-results states + artist/album/song sections. */ export default function AdvancedSearchResults({ showAdvancedPanel, hasSearched, loading, basicSearchMode, query, filteredResults, activeSearch, genreNote, songsHasMore, loadingMoreSongs, loadMoreSongs, artistRowScrollLeftRestoreRef, artistRowScrollLeftRef, albumRowScrollLeftRestoreRef, albumRowScrollLeftRef, }: AdvancedSearchResultsProps) { const { t } = useTranslation(); const total = filteredResults ? filteredResults.artists.length + filteredResults.albums.length + filteredResults.songs.length : 0; if (showAdvancedPanel && !hasSearched) { return (
{t('search.advancedEmpty')}
); } if (loading) { return (
); } if (total === 0) { return (
{basicSearchMode && query.trim() ? t('search.noResults', { query }) : t('search.advancedNoResults')}
); } return (
{filteredResults && filteredResults.artists.length > 0 && (
0 // React Compiler refs rule: ref read imperatively outside reactive rendering; not used to compute the render output. // eslint-disable-next-line react-hooks/refs ? artistRowScrollLeftRestoreRef.current : undefined } onScrollLeftSnapshot={(left) => { artistRowScrollLeftRef.current = left; }} />
)} {filteredResults && filteredResults.albums.length > 0 && (
0 // React Compiler refs rule: ref read imperatively outside reactive rendering; not used to compute the render output. // eslint-disable-next-line react-hooks/refs ? albumRowScrollLeftRestoreRef.current : undefined } onScrollLeftSnapshot={(left) => { albumRowScrollLeftRef.current = left; }} />
)} {filteredResults && filteredResults.songs.length > 0 && (

{t('search.songs')} {genreNote && ( — {t('search.advancedGenreNote')} )}

)}
); }