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>
|
</button>
|
||||||
{/* Unquittierte Favoriten für alle User */}
|
{/* Unquittierte Favoriten für alle User */}
|
||||||
{unackedFavs > 0 && (
|
{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)',
|
background:'rgba(245,158,11,0.12)', border:'1px solid rgba(245,158,11,0.35)',
|
||||||
borderRadius:7, color:'#f59e0b', cursor:'pointer',
|
borderRadius:7, color:'#f59e0b', cursor:'pointer',
|
||||||
padding:'4px 10px', fontSize:9, fontFamily:'monospace', letterSpacing:1,
|
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 [activeTool, setActiveTool] = useState('kino');
|
||||||
const [favIds, toggleFav] = useFavIds();
|
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(() => {
|
useEffect(() => {
|
||||||
if (initTab) {
|
const handler = (e) => setActiveTool(e.detail);
|
||||||
setActiveTool(initTab);
|
window.addEventListener('media-navigate', handler);
|
||||||
onInitTabConsumed?.();
|
return () => window.removeEventListener('media-navigate', handler);
|
||||||
}
|
}, []);
|
||||||
}, [initTab]);
|
|
||||||
const [modal, setModal] = useState(null); // { id, media_type }
|
const [modal, setModal] = useState(null); // { id, media_type }
|
||||||
const [xrelIds, setXrelIds] = useState(new Set()); // tmdb_ids mit bekannten Releases
|
const [xrelIds, setXrelIds] = useState(new Set()); // tmdb_ids mit bekannten Releases
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user