Merge branch 'next'

This commit is contained in:
ccd0 2016-03-19 21:27:46 -07:00
commit 1b8de6799d
3 changed files with 25 additions and 25 deletions

View File

@ -1013,6 +1013,6 @@ Config =
customCooldown: 0 customCooldown: 0
customCooldownEnabled: true customCooldownEnabled: true
pruneReplies: replyPruning:
'Prune Replies': false 'Prune Replies': false
'Max Replies': 1000 'Max Replies': 1000

View File

@ -446,7 +446,7 @@ Main =
['Keybinds', Keybinds] ['Keybinds', Keybinds]
['Banner', Banner] ['Banner', Banner]
['Flash Features', Flash] ['Flash Features', Flash]
['Prune Replies', PruneReplies] ['Reply Pruning', ReplyPruning]
<% if (tests_enabled) { %> <% if (tests_enabled) { %>
['Build Test', BuildTest] ['Build Test', BuildTest]
<% } %> <% } %>

View File

@ -1,4 +1,4 @@
PruneReplies = ReplyPruning =
init: -> init: ->
return unless g.VIEW is 'thread' and not Conf['Quote Threading'] return unless g.VIEW is 'thread' and not Conf['Quote Threading']
@ -21,7 +21,7 @@ PruneReplies =
order: 190 order: 190
Thread.callbacks.push Thread.callbacks.push
name: 'Prune Replies' name: 'Reply Pruning'
cb: @node cb: @node
position: 0 position: 0
@ -29,44 +29,44 @@ PruneReplies =
total: 0 total: 0
node: -> node: ->
PruneReplies.thread = @ ReplyPruning.thread = @
PruneReplies.total = @posts.keys.length - 1 ReplyPruning.total = @posts.keys.length - 1
$.on PruneReplies.inputs.enabled, 'change', PruneReplies.setEnabled $.on ReplyPruning.inputs.enabled, 'change', ReplyPruning.setEnabled
$.on PruneReplies.inputs.enabled, 'change', PruneReplies.update $.on ReplyPruning.inputs.enabled, 'change', ReplyPruning.update
if Conf['Prune Replies'] if Conf['Prune Replies']
PruneReplies.setEnabled() ReplyPruning.setEnabled()
PruneReplies.update() ReplyPruning.update()
setEnabled: -> setEnabled: ->
PruneReplies.container or= $.frag() ReplyPruning.container or= $.frag()
onOff = if Conf['Prune Replies'] then $.on else $.off onOff = if Conf['Prune Replies'] then $.on else $.off
onOff PruneReplies.inputs.replies, 'change', PruneReplies.update onOff ReplyPruning.inputs.replies, 'change', ReplyPruning.update
onOff d, 'ThreadUpdate', PruneReplies.update onOff d, 'ThreadUpdate', ReplyPruning.update
update: (e) -> update: (e) ->
if e and e.type is 'ThreadUpdate' and not e.detail[404] if e and e.type is 'ThreadUpdate' and not e.detail[404]
PruneReplies.total += e.detail.newPosts.length ReplyPruning.total += e.detail.newPosts.length
hidden2 = if Conf['Prune Replies'] hidden2 = if Conf['Prune Replies']
Math.max(PruneReplies.total - +Conf["Max Replies"], 0) Math.max(ReplyPruning.total - +Conf["Max Replies"], 0)
else else
0 0
{posts, OP} = PruneReplies.thread {posts, OP} = ReplyPruning.thread
if PruneReplies.hidden < hidden2 if ReplyPruning.hidden < hidden2
while PruneReplies.hidden < hidden2 and PruneReplies.position < posts.keys.length while ReplyPruning.hidden < hidden2 and ReplyPruning.position < posts.keys.length
post = posts[posts.keys[PruneReplies.position++]] post = posts[posts.keys[ReplyPruning.position++]]
if post.isReply and not post.isFetchedQuote if post.isReply and not post.isFetchedQuote
$.add PruneReplies.container, post.nodes.root $.add ReplyPruning.container, post.nodes.root
PruneReplies.hidden++ ReplyPruning.hidden++
else if PruneReplies.hidden > hidden2 else if ReplyPruning.hidden > hidden2
frag = $.frag() frag = $.frag()
while PruneReplies.hidden > hidden2 and PruneReplies.position > 0 while ReplyPruning.hidden > hidden2 and ReplyPruning.position > 0
post = posts[posts.keys[--PruneReplies.position]] post = posts[posts.keys[--ReplyPruning.position]]
if post.isReply and not post.isFetchedQuote if post.isReply and not post.isFetchedQuote
$.prepend frag, post.nodes.root $.prepend frag, post.nodes.root
PruneReplies.hidden-- ReplyPruning.hidden--
$.after OP.nodes.root, frag $.after OP.nodes.root, frag
$.event 'PostsInserted' $.event 'PostsInserted'