1
0
forked from w0bm/f0bm

more possible fixes for uploading

This commit is contained in:
x
2026-01-23 23:44:50 +01:00
parent a439683caf
commit 1a3514effa
2 changed files with 57 additions and 2 deletions

View File

@@ -161,17 +161,30 @@ export default (router, tpl) => {
}).end();
}
const page = +req.url.qs.page || 1;
const limit = 50;
const offset = (page - 1) * limit;
const total = (await db`select count(*) as c from "items" where active = 'false'`)[0].c;
const pages = Math.ceil(total / limit);
const _posts = await db`
select id, mime, username, dest
from "items"
where
active = 'false'
order by id desc
limit ${limit} offset ${offset}
`;
if (_posts.length === 0 && page > 1) {
// if page empty, maybe redirect to last page or page 1?
// Just render empty for now
}
if (_posts.length === 0) {
return res.reply({
body: tpl.render('admin/approve', { posts: [], tmp: null }, req)
body: tpl.render('admin/approve', { posts: [], pages: 0, page: 1, tmp: null }, req)
});
}
@@ -197,6 +210,8 @@ export default (router, tpl) => {
res.reply({
body: tpl.render('admin/approve', {
posts,
page,
pages,
tmp: null
}, req)
});