feat: send flags count to frontend on flags list page

This commit is contained in:
Julian Lam
2023-02-08 14:00:45 -05:00
parent 25c66eb37c
commit 2fde4ae3f7
3 changed files with 4 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
"reports": "Reports",
"first-reported": "First Reported",
"no-flags": "Hooray! No flags found.",
"x-flags-found": "%1 flag(s) found.",
"assignee": "Assignee",
"update": "Update",
"updated": "Updated",

View File

@@ -97,6 +97,7 @@ modsController.flags.list = async function (req, res) {
res.render('flags/list', {
flags: flagsData.flags,
count: flagsData.count,
analytics: analyticsData,
selectedCategory: selectData.selectedCategory,
hasFilter: hasFilter,

View File

@@ -191,6 +191,7 @@ Flags.list = async function (data) {
query: data.query,
});
flagIds = await Flags.sort(flagIds, data.sort);
const count = flagIds.length;
// Create subset for parsing based on page number (n=20)
const flagsPerPage = Math.abs(parseInt(filters.perPage, 10) || 1);
@@ -223,6 +224,7 @@ Flags.list = async function (data) {
return {
flags: payload.flags,
count,
page: payload.page,
pageCount: pageCount,
};