diff --git a/inc/compilePostComments.js b/inc/compilePostComments.js
index dcab27d..d014c9b 100644
--- a/inc/compilePostComments.js
+++ b/inc/compilePostComments.js
@@ -1,9 +1,8 @@
module.exports = function() {
- this.compilePostCommentsHtml = (comments, next_comment, post_id, post_url, morechildren_ids, post_author) => {
+ this.compilePostCommentsHtml = (comments, next_comment, post_id, post_url, morechildren_ids, post_author, viewing_comment) => {
return new Promise((resolve, reject) => {
(async () => {
let comments_html
-
function commentAuthor(comment, classlist, submitter, moderator) {
let classes = classlist.join(' ')
if (comment.author === '[deleted]')
@@ -71,9 +70,14 @@ module.exports = function() {
`
} else {
if(!morechildren_ids) {
+ let load_comms_href = parent_id
+
+ if(viewing_comment)
+ load_comms_href = '../' + parent_id
+
comments_html = `
`
} else {
@@ -152,17 +156,22 @@ module.exports = function() {
if(comment.replies[j+1]) {
next_reply = comment.replies[j+1]
}
- replies_html += await compilePostCommentsHtml(comment.replies[j], next_reply, post_id, post_url, null, post_author)
+ replies_html += await compilePostCommentsHtml(comment.replies[j], next_reply, post_id, post_url, null, post_author, viewing_comment)
}
}
}
comments_html += replies_html + ''
} else {
if(comment.children.length > 0) {
- let parent_id = comment.parent_id.split('_')[1]
+ let parent_id = comment.parent_id.split('_')[1]
+ let load_comms_href = parent_id
+
+ if(viewing_comment)
+ load_comms_href = '../' + parent_id
+
comments_html += `
`
} else {
diff --git a/inc/processJsonPost.js b/inc/processJsonPost.js
index b9f7e24..baa503c 100644
--- a/inc/processJsonPost.js
+++ b/inc/processJsonPost.js
@@ -186,7 +186,7 @@ module.exports = function(fetch) {
})
}
- this.finalizeJsonPost = async (processed_json, post_id, post_url, morechildren_ids) => {
+ this.finalizeJsonPost = async (processed_json, post_id, post_url, morechildren_ids, viewing_comment) => {
let comments_html = ``
diff --git a/routes.js b/routes.js
index b511427..60024c0 100644
--- a/routes.js
+++ b/routes.js
@@ -493,7 +493,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
(async () => {
if(!more_comments_cursor) {
let processed_json = await processJsonPost(json, false)
- let finalized_json = await finalizeJsonPost(processed_json, id, post_url)
+ let finalized_json = await finalizeJsonPost(processed_json, id, post_url, null, viewing_comment)
return res.render('post', {
post: finalized_json.post_data,
comments: finalized_json.comments,
@@ -558,7 +558,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
console.log(`Fetched the JSON from reddit.com${comments_url}.`);
(async () => {
let processed_json = await processJsonPost(json, true)
- let finalized_json = await finalizeJsonPost(processed_json, id, post_url)
+ let finalized_json = await finalizeJsonPost(processed_json, id, post_url, null, viewing_comment)
return res.render('post', {
post: finalized_json.post_data,
comments: finalized_json.comments,