fix: Custom Event für Media-Navigation (Dashboard-Badge → Favoriten-Tab)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user