add message count
This commit is contained in:
parent
23b04cfdac
commit
48eea8abe7
1 changed files with 13 additions and 2 deletions
|
@ -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' }
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue