fix: Badges + Releases persistent nach Reload via Cache-Check ohne xREL-Call

This commit is contained in:
2026-06-11 02:13:26 +02:00
parent 9076fbcc0b
commit 7ff6ce6da2
2 changed files with 36 additions and 3 deletions

View File

@@ -262,11 +262,20 @@ function KinoGrid({ onOpenModal, xrelIds }) {
const [error, setError] = useState('');
const [favIds, toggleFav] = useFavIds();
// Filme laden
// Filme laden + Cache-Status für Badges
useEffect(() => {
setLoading(true); setError('');
api('/tools/media/now-playing')
.then(setMovies)
.then(list => {
setMovies(list);
// Badges aus Cache laden (kein xREL-Call, nur DB)
const ids = list.map(m => m.id).join(',');
if (ids) api(`/tools/media/xrel-cached?ids=${ids}`)
.then(result => {
const hits = Object.entries(result).filter(([,v])=>v).map(([k])=>Number(k));
if (hits.length) setXrelIds(prev => new Set([...prev, ...hits]));
}).catch(()=>{});
})
.catch(e => setError(e.message))
.finally(() => setLoading(false));
}, []);
@@ -316,7 +325,15 @@ function DemnächstGrid({ onOpenModal, xrelIds }) {
useEffect(() => {
setLoading(true); setError('');
api('/tools/media/upcoming')
.then(setGroups)
.then(grps => {
setGroups(grps);
const ids = Object.values(grps).flat().map(m => m.id).join(',');
if (ids) api(`/tools/media/xrel-cached?ids=${ids}`)
.then(result => {
const hits = Object.entries(result).filter(([,v])=>v).map(([k])=>Number(k));
if (hits.length) setXrelIds(prev => new Set([...prev, ...hits]));
}).catch(()=>{});
})
.catch(e => setError(e.message))
.finally(() => setLoading(false));
}, []);
@@ -450,6 +467,10 @@ function MovieModal({ tmdbId, onClose, mobile, onHasXrel }) {
api(`/tools/media/movie/${tmdbId}`)
.then(d => { setDetail(d); setLoading(false); })
.catch(e => { setError(e.message); setLoading(false); });
// Cached Releases sofort laden falls vorhanden
api(`/tools/media/movie/${tmdbId}/xrel`)
.then(d => { if (d.xrel?.length) { setXrel(d.xrel); onHasXrel?.(tmdbId); } })
.catch(()=>{});
const prev = document.body.style.overflow;
document.body.style.overflow = 'hidden';
return () => { document.body.style.overflow = prev; };