correct omitted reply count

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

@ -61,8 +61,13 @@ module.exports = {
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);
const latestPreviewBacklink = thread.backlinks.find(bl => { return bl.postId >= firstPreviewId });
if (latestPreviewBacklink != null) {
const latestPreviewIndex = thread.backlinks.map(bl => bl.postId).indexOf(latestPreviewBacklink);
thread.previewbacklinks = thread.backlinks.slice(latestPreviewIndex);
} else {
thread.previewbacklinks = [];
}
//cout omitted image and posts
const numPreviewImages = replies.reduce((acc, post) => { return acc + post.files.length }, 0);
thread.omittedimages = thread.replyfiles - numPreviewImages;

@ -94,11 +94,14 @@ mixin post(post, truncate, manage=false, globalmanage=false)
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
.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
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}`) &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