more possible fixes for uploading
This commit is contained in:
@@ -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)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user