Loading notifications async.

This commit is contained in:
2024-05-28 03:48:50 +02:00
parent 652c389840
commit 70882e0baf
5 changed files with 274 additions and 231 deletions

View File

@@ -52,7 +52,7 @@ import {
updateNotificationsApi,
} from './alerts.js';
import { fetchNotifications } from '../alerts.js';
import { fetchUnseenNotificationsCount } from '../alerts.js';
import initLogger from '../logger.js';
@@ -168,7 +168,7 @@ export default async function initServer() {
router.get('/api/tags', fetchTagsApi);
router.get('*', async (req, res, next) => {
const notifications = await fetchNotifications(req.user, { limit: 20 });
const unseenNotifications = await fetchUnseenNotificationsCount(req.user);
const pageContextInit = {
urlOriginal: req.originalUrl,
@@ -191,7 +191,9 @@ export default async function initServer() {
maxAggregateSize: config.database.manticore.maxAggregateSize,
media: config.media,
},
notifications,
meta: {
unseenNotifications,
},
};
const pageContext = await renderPage(pageContextInit);