Remember number of replies to contract thread to instead of hardcoding it for each board. #525

This commit is contained in:
ccd0 2019-07-22 00:25:28 -07:00
parent 5814dadcf7
commit 0176c350a0

View File

@ -58,6 +58,7 @@ ExpandThread =
return if @ isnt status.req # aborted
delete status.req
ExpandThread.parse @, thread, a
status.numReplies = $$(g.SITE.selectors.postContainer + g.SITE.selectors.relative.replyPost, thread.nodes.root).length
contract: (thread, a, threadRoot) ->
status = ExpandThread.statuses[thread]
@ -69,15 +70,7 @@ ExpandThread =
return
replies = $$ '.thread > .replyContainer', threadRoot
if !Conf['JSON Index'] or Conf['Show Replies']
num = if thread.isSticky
1
else switch g.BOARD.ID
# XXX boards config
when 'b', 'vg', 'bant' then 3
when 't' then 1
else 5
replies = replies[...-num]
replies = replies[...(-status.numReplies)] if status.numReplies
postsCount = 0
filesCount = 0
for reply in replies