fix: kein Auto-Load im Modal, Button immer frisch suchen, Cache nur für befüllte Einträge

This commit is contained in:
2026-06-11 02:21:09 +02:00
parent 7ff6ce6da2
commit c677e04dc6
2 changed files with 17 additions and 18 deletions

View File

@@ -467,25 +467,23 @@ 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; };
}, [tmdbId]);
const searchXrel = async (refresh = false) => {
const searchXrel = async () => {
if (!detail) return;
setXrelLoading(true);
try {
// Immer refresh=1: ignoriert leere Cache-Einträge, sucht frisch
// Befüllte Cache-Einträge werden trotzdem sofort zurückgegeben (Backend-Logik)
const params = new URLSearchParams({
title: detail.title || '',
orig: detail.original_title || '',
title: detail.title || '',
orig: detail.original_title || '',
imdb_id: detail.imdb_id || '',
refresh: '1',
});
if (refresh) params.set('refresh', '1');
const d = await api(`/tools/media/movie/${tmdbId}/xrel?${params}`);
setXrel(d.xrel || []);
if (d.has_xrel) onHasXrel?.(tmdbId);
@@ -631,7 +629,7 @@ function MovieModal({ tmdbId, onClose, mobile, onHasXrel }) {
<div style={{ display:'flex', alignItems:'center', gap:8, marginBottom: xrel?.length ? 8 : 0 }}>
<div style={{ ...S.head, marginBottom:0, flex:1 }}>RELEASES (XREL.TO)</div>
<button
onClick={() => searchXrel(xrel !== null)}
onClick={() => searchXrel()}
disabled={xrelLoading}
style={{
fontSize:10, fontFamily:'monospace', cursor: xrelLoading ? 'default' : 'pointer',
@@ -640,7 +638,7 @@ function MovieModal({ tmdbId, onClose, mobile, onHasXrel }) {
borderRadius:6, padding:'3px 10px', flexShrink:0,
}}
>
{xrelLoading ? '⏳ Suche…' : xrel === null ? '🔍 Suchen' : '🔄 Aktualisieren'}
{xrelLoading ? '⏳ Suche…' : xrel === null ? '🔍 Nach Releases suchen' : '🔄 Erneut suchen'}
</button>
</div>
{xrel !== null && xrel.length === 0 && (