fix 'continue this thread' links (fixes #82)
This commit is contained in:
parent
8af3ec3591
commit
02fd92ce2c
|
@ -1,5 +1,5 @@
|
||||||
module.exports = function() {
|
module.exports = function() {
|
||||||
this.compilePostCommentsHtml = (comments, next_comment, post_id, post_url, morechildren_ids, post_author, viewing_comment, user_preferences, last_known_depth) => {
|
this.compilePostCommentsHtml = (comments, next_comment, post_id, post_url, morechildren_ids, post_author, viewing_comment, user_preferences, last_known_depth, req_url) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
let comments_html
|
let comments_html
|
||||||
|
@ -115,6 +115,9 @@ module.exports = function() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let link = comments.parent_id.split('_')[1]
|
let link = comments.parent_id.split('_')[1]
|
||||||
|
if (req_url.slice(-1) === '/') {
|
||||||
|
link = '../' + link
|
||||||
|
}
|
||||||
comments_html = `
|
comments_html = `
|
||||||
<div class="load-more-comments">
|
<div class="load-more-comments">
|
||||||
<a href="${link}/#c">continue this thread</a>
|
<a href="${link}/#c">continue this thread</a>
|
||||||
|
@ -199,7 +202,7 @@ module.exports = function() {
|
||||||
if(comment.replies[j+1]) {
|
if(comment.replies[j+1]) {
|
||||||
next_reply = 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, viewing_comment, user_preferences)
|
replies_html += await compilePostCommentsHtml(comment.replies[j], next_reply, post_id, post_url, null, post_author, viewing_comment, user_preferences, null, req_url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,7 +218,10 @@ module.exports = function() {
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
} else {
|
} else {
|
||||||
let link = comment.parent_id.split('_')[1]
|
let link = comment.parent_id.split('_')[1]
|
||||||
|
if (req_url.slice(-1) === '/') {
|
||||||
|
link = '../' + link
|
||||||
|
}
|
||||||
comments_html = `
|
comments_html = `
|
||||||
<div class="load-more-comments">
|
<div class="load-more-comments">
|
||||||
<a href="${link}/#c">continue this thread</a>
|
<a href="${link}/#c">continue this thread</a>
|
||||||
|
|
|
@ -365,7 +365,8 @@ async function finalizeJsonPost(
|
||||||
post_url,
|
post_url,
|
||||||
morechildren_ids,
|
morechildren_ids,
|
||||||
viewing_comment,
|
viewing_comment,
|
||||||
user_preferences
|
user_preferences,
|
||||||
|
req_url
|
||||||
) {
|
) {
|
||||||
let comments_html = `<div class="comments">`;
|
let comments_html = `<div class="comments">`;
|
||||||
let comments = processed_json.comments;
|
let comments = processed_json.comments;
|
||||||
|
@ -388,7 +389,8 @@ async function finalizeJsonPost(
|
||||||
processed_json.author,
|
processed_json.author,
|
||||||
viewing_comment,
|
viewing_comment,
|
||||||
user_preferences,
|
user_preferences,
|
||||||
last_known_depth
|
last_known_depth,
|
||||||
|
req_url
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -682,7 +682,8 @@ subredditRoutes.get(
|
||||||
post_url,
|
post_url,
|
||||||
more_comments,
|
more_comments,
|
||||||
viewing_comment,
|
viewing_comment,
|
||||||
req.cookies
|
req.cookies,
|
||||||
|
req.url
|
||||||
);
|
);
|
||||||
return res.render('post', {
|
return res.render('post', {
|
||||||
post: finalized_json.post_data,
|
post: finalized_json.post_data,
|
||||||
|
@ -758,7 +759,9 @@ subredditRoutes.get(
|
||||||
id,
|
id,
|
||||||
post_url,
|
post_url,
|
||||||
more_comments,
|
more_comments,
|
||||||
viewing_comment
|
viewing_comment,
|
||||||
|
req.cookies,
|
||||||
|
req.url
|
||||||
);
|
);
|
||||||
return res.render('post', {
|
return res.render('post', {
|
||||||
post: finalized_json.post_data,
|
post: finalized_json.post_data,
|
||||||
|
|
Loading…
Reference in New Issue