add message count

This commit is contained in:
biglyderv 2025-03-03 13:51:06 -05:00
parent 23b04cfdac
commit 48eea8abe7
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5

View file

@ -88,12 +88,23 @@ async function auther(req, res, next) {
next();
}
function initr(req, res, next) {
async function initr(req, res, next) {
let msgCount = 0;
if (res.auth.valid) {
let messages = await db.all('SELECT count(*) FROM messages WHERE username = ? AND status = ?', [
res.auth.username,
'unread'
]);
msgCount = messages[0]['count(*)'];
}
let headerCtx = [
{ link: '/walls/get/hub/main/0', icon: '/icon.svg', name: 'DervNet' },
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
{ link: '/users/' + (res.auth ? res.auth.username : ''), icon: '/login.svg', name: 'You' },
{ link: '/you/messages', icon: '/mail.svg', name: 'Messages' },
{ link: '/you/messages', icon: '/mail.svg', name: `Messages [${msgCount}]` },
{ link: '/you/logout', icon: '/logout.svg', name: 'Leave' }
];