Compare commits
1 Commits
231887c3b7
...
f5a6b919aa
| Author | SHA1 | Date | |
|---|---|---|---|
| f5a6b919aa |
@@ -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 ??
|
||||
|
||||
Reference in New Issue
Block a user