comments and replies work now
This commit is contained in:
parent
11147482d2
commit
9e5989825f
6 changed files with 102 additions and 10 deletions
|
@ -22,20 +22,24 @@ router.get('/:id', async (req, res, next) => {
|
|||
|
||||
for (let reply of replies) {
|
||||
let dat = await db.all('SELECT * FROM comment WHERE id = ?', [
|
||||
reply.parentId
|
||||
reply.childId
|
||||
]);
|
||||
if (reply.parentType != 'comment' || dat.length < 1) {
|
||||
reply.comment = {username: 'fail', date: 'fail', content: 'fail'};
|
||||
if (reply.childType != 'comment' || dat.length < 1) {
|
||||
reply.comment = 'fail'
|
||||
continue;
|
||||
}
|
||||
reply.comment = dat[0];
|
||||
reply.comment.id = reply.childId;
|
||||
reply.comment.type = reply.childType;
|
||||
}
|
||||
|
||||
replies = replies.filter(x => x.comment != 'fail');
|
||||
|
||||
console.log(replies)
|
||||
|
||||
res.ctx.mainPage = 'commenter'
|
||||
res.ctx.mainCtx = {
|
||||
replies,
|
||||
opLink: `/comments/${req.params.id}`
|
||||
replies
|
||||
}
|
||||
next();
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue