preview backlink corrections for 0 links and incorrect indexOf for all 5

merge-requests/208/head
fatchan 5 years ago
parent 7d7f43373e
commit 69b37e2a35
  1. 6
      db/posts.js
  2. 15
      views/mixins/post.pug

@ -60,10 +60,10 @@ module.exports = {
//if enough replies, show omitted count
if (thread.replyposts > 5) {
//dont show ALL backlinks on OP for previews on index page
const firstPreviewId = thread.replies[0].postId;
const latestPreviewBacklink = thread.backlinks.find(bl => { return bl.postId >= firstPreviewId });
const firstPreviewId = thread.replies[0].postId; //34
const latestPreviewBacklink = thread.backlinks.find(bl => { return bl.postId >= firstPreviewId }); //post with 34
if (latestPreviewBacklink != null) {
const latestPreviewIndex = thread.backlinks.map(bl => bl.postId).indexOf(latestPreviewBacklink);
const latestPreviewIndex = thread.backlinks.map(bl => bl.postId).indexOf(latestPreviewBacklink.postId);
thread.previewbacklinks = thread.backlinks.slice(latestPreviewIndex);
} else {
thread.previewbacklinks = [];

@ -92,16 +92,13 @@ mixin post(post, truncate, manage=false, globalmanage=false)
blockquote.banmessage USER BANNED FOR THIS POST (#{post.banmessage || 'No reason specified'})
if post.omittedposts || post.omittedimages
blockquote.muted #{post.omittedposts} post(s)#{post.omittedimages > 0 ? ' and '+post.omittedimages+' image(s)' : ''} omitted. #[a(href=`${postURL}#${post.postId}`) View the full thread]
if post.previewbacklinks
if post.previewbacklinks && post.previewbacklinks.length > 0
.replies Replies:
if post.previewbacklinks.length === 0
| #{post.backlinks.length-post.previewbacklinks.length} reply link(s) omitted
else
each backlink in post.previewbacklinks
a.quote(href=`/${post.board}/thread/${post.thread || post.postId}.html#${backlink.postId}`) >>#{backlink.postId}
|
if post.previewbacklinks.length < post.backlinks.length
| + #{post.backlinks.length-post.previewbacklinks.length} reply link(s) omitted
each backlink in post.previewbacklinks
a.quote(href=`/${post.board}/thread/${post.thread || post.postId}.html#${backlink.postId}`) &gt;&gt;#{backlink.postId}
|
if post.previewbacklinks.length < post.backlinks.length
| + #{post.backlinks.length-post.previewbacklinks.length} reply link(s) omitted
else if post.backlinks && post.backlinks.length > 0
.replies Replies:
each backlink in post.backlinks

Loading…
Cancel
Save