fix: Custom Event für Media-Navigation (Dashboard-Badge → Favoriten-Tab)

This commit is contained in:
2026-06-18 15:10:04 +02:00
parent f17a957d6f
commit 62565d95a8
2 changed files with 6 additions and 7 deletions

View File

@@ -1983,7 +1983,7 @@ function Dashboard({ toast, mobile, setActive, setDevToolsNav, unreadMsgs=0, unr
</button>
{/* Unquittierte Favoriten für alle User */}
{unackedFavs > 0 && (
<button onClick={()=>{ setMediaInitTab('favoriten'); setActive('media'); }} style={{
<button onClick={()=>{ setActive('media'); setTimeout(()=>window.dispatchEvent(new CustomEvent('media-navigate',{detail:'favoriten'})),80); }} style={{
background:'rgba(245,158,11,0.12)', border:'1px solid rgba(245,158,11,0.35)',
borderRadius:7, color:'#f59e0b', cursor:'pointer',
padding:'4px 10px', fontSize:9, fontFamily:'monospace', letterSpacing:1,

View File

@@ -42,13 +42,12 @@ export default function Media({ toast, mobile, initTab, onInitTabConsumed }) {
const [activeTool, setActiveTool] = useState('kino');
const [favIds, toggleFav] = useFavIds();
// Wenn von außen ein Tab vorgegeben wird (z.B. Dashboard-Badge)
// Auf Custom Event hören (z.B. Dashboard-Badge → Favoriten)
useEffect(() => {
if (initTab) {
setActiveTool(initTab);
onInitTabConsumed?.();
}
}, [initTab]);
const handler = (e) => setActiveTool(e.detail);
window.addEventListener('media-navigate', handler);
return () => window.removeEventListener('media-navigate', handler);
}, []);
const [modal, setModal] = useState(null); // { id, media_type }
const [xrelIds, setXrelIds] = useState(new Set()); // tmdb_ids mit bekannten Releases