diff --git a/backend/src/routes/dashboard.js b/backend/src/routes/dashboard.js index 37369d0..61d7e10 100644 --- a/backend/src/routes/dashboard.js +++ b/backend/src/routes/dashboard.js @@ -147,8 +147,8 @@ router.get('/board/unread', authenticate, (req, res) => { ? db.prepare("SELECT COUNT(*) c FROM board_items WHERE created_at > ? AND user_id != ?").get(lastRead, u).c : db.prepare('SELECT COUNT(*) c FROM board_items WHERE user_id != ?').get(u).c; const unreadPromoted = lastRead - ? db.prepare("SELECT COUNT(*) c FROM board_items WHERE promoted_at > ? AND user_id != ?").get(lastRead, u).c - : db.prepare("SELECT COUNT(*) c FROM board_items WHERE promoted_at IS NOT NULL AND user_id != ?").get(u).c; + ? db.prepare("SELECT COUNT(*) c FROM board_items WHERE promoted_at > ?").get(lastRead).c + : db.prepare("SELECT COUNT(*) c FROM board_items WHERE promoted_at IS NOT NULL").get().c; res.json({ unread, unreadPromoted }); }); diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index d19442b..78dc7b2 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -990,17 +990,13 @@ function BoardModal({ user, toast, onClose, onRead }) { } -function Dashboard({ toast, mobile, setActive, unreadMsgs=0, unreadBoard=0, unreadPromoted=0, user }) { +function Dashboard({ toast, mobile, setActive, unreadMsgs=0, unreadBoard=0, unreadPromoted=0, onBoardRead, user }) { const [now, setNow] = useState(new Date()); - const [showBoard, setShowBoard] = useState(false); - const [boardUnread, setBoardUnread] = useState(unreadBoard); - const [promotedUnread, setPromotedUnread] = useState(unreadPromoted); - useEffect(()=>{ setBoardUnread(unreadBoard); },[unreadBoard]); - useEffect(()=>{ setPromotedUnread(unreadPromoted); },[unreadPromoted]); + const [showBoard, setShowBoard] = useState(false); useEffect(() => { const t = setInterval(() => setNow(new Date()), 30000); return () => clearInterval(t); }, []); return (
- {showBoard && setShowBoard(false)} onRead={()=>{ setBoardUnread(0); setPromotedUnread(0); }}/>} + {showBoard && setShowBoard(false)} onRead={onBoardRead}/>}

Dashboard

@@ -1032,15 +1028,15 @@ function Dashboard({ toast, mobile, setActive, unreadMsgs=0, unreadBoard=0, unre color:'rgba(255,255,255,0.45)', cursor:'pointer', padding:'4px 10px', fontSize:9, fontFamily:'monospace', letterSpacing:1 }}> 📋 ToDo - {boardUnread > 0 && ( + {unreadBoard > 0 && ( )} - {promotedUnread > 0 && boardUnread === 0 && ( + {unreadPromoted > 0 && unreadBoard === 0 && ( )} - {promotedUnread > 0 && boardUnread > 0 && ( + {unreadPromoted > 0 && unreadBoard > 0 && ( )} @@ -1841,7 +1837,7 @@ export default function App() { if(!user)return; const poll=()=>api('/dashboard/board/unread').then(d=>{ setUnreadBoard(d.unread||0); setUnreadPromoted(d.unreadPromoted||0); }).catch(()=>{}); poll(); - const t=setInterval(poll,60*1000); + const t=setInterval(poll,30*1000); return()=>clearInterval(t); },[user]); @@ -1892,7 +1888,7 @@ export default function App() { unreadMsgs={unreadMsgs}/> )}
- {active==='dashboard' && } + {active==='dashboard' && { setUnreadBoard(0); setUnreadPromoted(0); }} user={user}/>} {active==='admin' && } {activeTool && }