From 67b09cba5f6242e11e1fd1cbb4361b25a10bd911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 24 Mar 2021 12:41:37 -0400 Subject: [PATCH] fix: #9420, paginate after loading notifications --- src/controllers/accounts/notifications.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/controllers/accounts/notifications.js b/src/controllers/accounts/notifications.js index 2eed832c2d..f6481c8a5f 100644 --- a/src/controllers/accounts/notifications.js +++ b/src/controllers/accounts/notifications.js @@ -51,11 +51,12 @@ notificationsController.get = async function (req, res, next) { if (!selectedFilter) { return next(); } - let nids = await user.notifications.getAll(req.uid, selectedFilter.filter); - const pageCount = Math.max(1, Math.ceil(nids.length / itemsPerPage)); - nids = nids.slice(start, stop + 1); - const notifications = await user.notifications.getNotifications(nids, req.uid); + const nids = await user.notifications.getAll(req.uid, selectedFilter.filter); + let notifications = await user.notifications.getNotifications(nids, req.uid); + + const pageCount = Math.max(1, Math.ceil(notifications.length / itemsPerPage)); + notifications = notifications.slice(start, stop + 1); res.render('notifications', { notifications: notifications,