From 3b5779f371b46839e8625c83bc944d48c7e6363d Mon Sep 17 00:00:00 2001 From: teddit Date: Sat, 21 Nov 2020 15:37:46 +0100 Subject: [PATCH] fix an issue when user doesnt have any posts/comments --- inc/processJsonUser.js | 10 ++++++++-- views/user.pug | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/inc/processJsonUser.js b/inc/processJsonUser.js index 892b0cc..f081138 100644 --- a/inc/processJsonUser.js +++ b/inc/processJsonUser.js @@ -22,8 +22,14 @@ module.exports = function() { user_front = true } - after = json.overview.data.children[posts_limit - 1].data.name - before = json.overview.data.children[0].data.name + if(json.overview.data.children) { + if(json.overview.data.children[posts_limit - 1]) { + after = json.overview.data.children[posts_limit - 1].data.name + } + if(json.overview.data.children[0]) { + before = json.overview.data.children[0].data.name + } + } for(var i = 0; i < posts_limit; i++) { let post = json.overview.data.children[i].data diff --git a/views/user.pug b/views/user.pug index 112d880..acb336d 100644 --- a/views/user.pug +++ b/views/user.pug @@ -59,6 +59,8 @@ html li(class=past === 'all' ? 'active' : '') a(href="?sort=" + sortby + "&t=all") all time .entries + if !data.posts || data.posts.length <= 0 + h3 no posts/comments each post in data.posts if post.type === 't3' .entry.t3