diff --git a/src/features/library/LibraryPage.tsx b/src/features/library/LibraryPage.tsx index 79e6ec4..a4eeec8 100644 --- a/src/features/library/LibraryPage.tsx +++ b/src/features/library/LibraryPage.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { useNavigate } from 'react-router'; import { useTranslation } from 'react-i18next'; import { @@ -54,8 +54,14 @@ export function LibraryPage() { const [search, setSearch] = useState(''); const [debouncedSearch] = useDebounce(search, 300); + // Poll while any listed track is still being enriched, then stop. Enrichment + // runs asynchronously in a worker after import/upload; without this the row + // stays stuck on "Identifying metadata…" until something else invalidates the + // Track tag. Cleared to 0 once nothing is pending (and while offline). + const [tracksPollMs, setTracksPollMs] = useState(0); const tracksQuery = useGetTracksQuery( debouncedSearch ? { search } : undefined, + { pollingInterval: tracksPollMs }, ); const albumsQuery = useGetAlbumsQuery( debouncedSearch ? { search } : undefined, @@ -73,6 +79,14 @@ export function LibraryPage() { const localArtists = useAppSelector(selectLocalArtists); const q = debouncedSearch.trim().toLowerCase(); + const anyPending = + !offline && + (tracksQuery.data?.items.some((tr) => tr.metadataStatus === 'pending') ?? + false); + useEffect(() => { + setTracksPollMs(anyPending ? 4000 : 0); + }, [anyPending]); + // Live server data wins; offline we fall back to the locally-composed list. const tracksToShow = tracksQuery.data?.items ??