Board: Auto-Update fix, gelber Punkt für Ersteller, Poll 30s

This commit is contained in:
2026-05-28 18:53:12 +02:00
parent b66a373764
commit cc6a1c6dc7
2 changed files with 10 additions and 14 deletions

View File

@@ -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 created_at > ? AND user_id != ?").get(lastRead, u).c
: db.prepare('SELECT COUNT(*) c FROM board_items WHERE user_id != ?').get(u).c; : db.prepare('SELECT COUNT(*) c FROM board_items WHERE user_id != ?').get(u).c;
const unreadPromoted = lastRead 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 > ?").get(lastRead).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 IS NOT NULL").get().c;
res.json({ unread, unreadPromoted }); res.json({ unread, unreadPromoted });
}); });

View File

@@ -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 [now, setNow] = useState(new Date());
const [showBoard, setShowBoard] = useState(false); const [showBoard, setShowBoard] = useState(false);
const [boardUnread, setBoardUnread] = useState(unreadBoard);
const [promotedUnread, setPromotedUnread] = useState(unreadPromoted);
useEffect(()=>{ setBoardUnread(unreadBoard); },[unreadBoard]);
useEffect(()=>{ setPromotedUnread(unreadPromoted); },[unreadPromoted]);
useEffect(() => { const t = setInterval(() => setNow(new Date()), 30000); return () => clearInterval(t); }, []); useEffect(() => { const t = setInterval(() => setNow(new Date()), 30000); return () => clearInterval(t); }, []);
return ( return (
<div style={{ padding: mobile ? '14px 12px 90px' : '36px 44px', maxWidth:1100 }}> <div style={{ padding: mobile ? '14px 12px 90px' : '36px 44px', maxWidth:1100 }}>
{showBoard && <BoardModal user={user} toast={toast} onClose={()=>setShowBoard(false)} onRead={()=>{ setBoardUnread(0); setPromotedUnread(0); }}/>} {showBoard && <BoardModal user={user} toast={toast} onClose={()=>setShowBoard(false)} onRead={onBoardRead}/>}
<div style={{ marginBottom:16, display:'flex', alignItems:'flex-start', justifyContent:'space-between' }}> <div style={{ marginBottom:16, display:'flex', alignItems:'flex-start', justifyContent:'space-between' }}>
<div> <div>
<h1 style={{ color:'#fff', fontFamily:"'Space Mono',monospace", fontSize:mobile ? 17 : 22, margin:0 }}>Dashboard</h1> <h1 style={{ color:'#fff', fontFamily:"'Space Mono',monospace", fontSize:mobile ? 17 : 22, margin:0 }}>Dashboard</h1>
@@ -1032,15 +1028,15 @@ function Dashboard({ toast, mobile, setActive, unreadMsgs=0, unreadBoard=0, unre
color:'rgba(255,255,255,0.45)', cursor:'pointer', color:'rgba(255,255,255,0.45)', cursor:'pointer',
padding:'4px 10px', fontSize:9, fontFamily:'monospace', letterSpacing:1 }}> padding:'4px 10px', fontSize:9, fontFamily:'monospace', letterSpacing:1 }}>
📋 ToDo 📋 ToDo
{boardUnread > 0 && ( {unreadBoard > 0 && (
<span style={{ position:'absolute', top:-3, right:-3, width:7, height:7, <span style={{ position:'absolute', top:-3, right:-3, width:7, height:7,
borderRadius:'50%', background:'#4ecdc4', boxShadow:'0 0 5px #4ecdc4' }}/> borderRadius:'50%', background:'#4ecdc4', boxShadow:'0 0 5px #4ecdc4' }}/>
)} )}
{promotedUnread > 0 && boardUnread === 0 && ( {unreadPromoted > 0 && unreadBoard === 0 && (
<span style={{ position:'absolute', top:-3, right:-3, width:7, height:7, <span style={{ position:'absolute', top:-3, right:-3, width:7, height:7,
borderRadius:'50%', background:'#ffe66d', boxShadow:'0 0 5px #ffe66d' }}/> borderRadius:'50%', background:'#ffe66d', boxShadow:'0 0 5px #ffe66d' }}/>
)} )}
{promotedUnread > 0 && boardUnread > 0 && ( {unreadPromoted > 0 && unreadBoard > 0 && (
<span style={{ position:'absolute', top:-3, left:-3, width:7, height:7, <span style={{ position:'absolute', top:-3, left:-3, width:7, height:7,
borderRadius:'50%', background:'#ffe66d', boxShadow:'0 0 5px #ffe66d' }}/> borderRadius:'50%', background:'#ffe66d', boxShadow:'0 0 5px #ffe66d' }}/>
)} )}
@@ -1841,7 +1837,7 @@ export default function App() {
if(!user)return; if(!user)return;
const poll=()=>api('/dashboard/board/unread').then(d=>{ setUnreadBoard(d.unread||0); setUnreadPromoted(d.unreadPromoted||0); }).catch(()=>{}); const poll=()=>api('/dashboard/board/unread').then(d=>{ setUnreadBoard(d.unread||0); setUnreadPromoted(d.unreadPromoted||0); }).catch(()=>{});
poll(); poll();
const t=setInterval(poll,60*1000); const t=setInterval(poll,30*1000);
return()=>clearInterval(t); return()=>clearInterval(t);
},[user]); },[user]);
@@ -1892,7 +1888,7 @@ export default function App() {
unreadMsgs={unreadMsgs}/> unreadMsgs={unreadMsgs}/>
)} )}
<main style={mainStyle}> <main style={mainStyle}>
{active==='dashboard' && <Dashboard toast={toast} mobile={mobile} setActive={setActive} unreadMsgs={unreadMsgs} unreadBoard={unreadBoard} unreadPromoted={unreadPromoted} user={user}/>} {active==='dashboard' && <Dashboard toast={toast} mobile={mobile} setActive={setActive} unreadMsgs={unreadMsgs} unreadBoard={unreadBoard} unreadPromoted={unreadPromoted} onBoardRead={()=>{ setUnreadBoard(0); setUnreadPromoted(0); }} user={user}/>}
{active==='admin' && <AdminPanel toast={toast} mobile={mobile} user={user}/>} {active==='admin' && <AdminPanel toast={toast} mobile={mobile} user={user}/>}
{activeTool && <activeTool.component toast={toast} mobile={mobile} setActive={setActive}/>} {activeTool && <activeTool.component toast={toast} mobile={mobile} setActive={setActive}/>}
</main> </main>