From 8d727ed555ddfc72dc665dc7167fceaea2d1014e Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 17 Oct 2018 05:33:36 -0700 Subject: [PATCH] Fix bug in reply count shown on thread stubs. --- src/General/Build.coffee | 6 +++--- src/General/Index.coffee | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 24cd916b5..ccf890dc1 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -178,7 +178,7 @@ Build = textContent: Build.summaryText '', posts, files href: "/#{boardID}/thread/#{threadID}" - thread: (thread, data) -> + thread: (thread, data, withReplies) -> if (root = thread.nodes.root) $.rmAll root else @@ -187,8 +187,8 @@ Build = id: "t#{data.no}" $.add root, Build.hat.cloneNode(false) if Build.hat $.add root, thread.OP.nodes.root - if data.omitted_posts or !Conf['Show Replies'] and data.replies - [posts, files] = if Conf['Show Replies'] + if data.omitted_posts or !withReplies and data.replies + [posts, files] = if withReplies # XXX data.omitted_images is not accurate. [data.omitted_posts, data.images - data.last_replies.filter((data) -> !!data.ext).length] else diff --git a/src/General/Index.coffee b/src/General/Index.coffee index f9feef8c6..910959084 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -691,7 +691,7 @@ Index = isHiddenReply: (threadID, replyData) -> PostHiding.isHidden(g.BOARD.ID, threadID, replyData.no) or Filter.isHidden(Build.parseJSON replyData, g.BOARD.ID) - buildThreads: (threadIDs, isCatalog) -> + buildThreads: (threadIDs, isCatalog, withReplies) -> threads = [] newThreads = [] newPosts = [] @@ -724,7 +724,8 @@ Index = OP.filterResults = obj.filterResults newPosts.push OP - Build.thread thread, threadData unless isCatalog and thread.nodes.root + unless isCatalog and thread.nodes.root + Build.thread thread, threadData, withReplies catch err # Skip posts that we failed to parse. errors = [] unless errors @@ -733,6 +734,9 @@ Index = error: err Main.handleErrors errors if errors + if withReplies + newPosts = newPosts.concat(Index.buildReplies threads) + Main.callbackNodes 'Thread', newThreads Main.callbackNodes 'Post', newPosts Index.updateHideLabel() @@ -761,7 +765,7 @@ Index = $.add thread.nodes.root, nodes Main.handleErrors errors if errors - Main.callbackNodes 'Post', posts + posts buildCatalogViews: (threads) -> catalogThreads = [] @@ -873,8 +877,7 @@ Index = Index.sortedThreadIDs[offset ... offset + nodesPerPage] buildStructure: (threadIDs) -> - threads = Index.buildThreads threadIDs, false - Index.buildReplies threads if Conf['Show Replies'] + threads = Index.buildThreads threadIDs, false, Conf['Show Replies'] nodes = [] for thread in threads nodes.push thread.nodes.root, $.el('hr')