limit and show omitted replies on index page when backlinks link to post not shown in preview

merge-requests/208/head
fatchan 5 years ago
parent 0f3dbfa931
commit 4a8a54828d
  1. 4
      db/posts.js
  2. 9
      views/mixins/post.pug

@ -59,6 +59,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 firstPreviewBacklinkIndex = thread.backlinks.map(bl => bl.postId).indexOf(firstPreviewId);
thread.previewbacklinks = thread.backlinks.slice(firstPreviewBacklinkIndex);
//cout omitted image and posts
const numPreviewImages = replies.reduce((acc, post) => { return acc + post.files.length }, 0);
thread.omittedimages = thread.replyfiles - numPreviewImages;

@ -92,7 +92,14 @@ 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.backlinks && post.backlinks.length > 0
if post.previewbacklinks
.replies Replies:
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
else if post.backlinks && post.backlinks.length > 0
.replies Replies:
each backlink in post.backlinks
a.quote(href=`/${post.board}/thread/${post.thread || post.postId}.html#${backlink.postId}`) &gt;&gt;#{backlink.postId}

Loading…
Cancel
Save