From 67d22a15e9f1df70ab174caa5cd195eb9b2b9b8a Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 7 Nov 2016 12:19:54 -0800 Subject: [PATCH] Add `Prune by Default` option (default: false): Turn Reply Pruning on by default in all threads, except when navigating to a post that would be hidden. #1115 --- src/Monitoring/ReplyPruning.coffee | 8 +++----- src/Quotelinks/QuoteThreading.coffee | 10 ++++++---- src/config/Config.coffee | 5 +++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Monitoring/ReplyPruning.coffee b/src/Monitoring/ReplyPruning.coffee index 481efaf0b..1c419ba02 100644 --- a/src/Monitoring/ReplyPruning.coffee +++ b/src/Monitoring/ReplyPruning.coffee @@ -2,8 +2,6 @@ ReplyPruning = init: -> return unless g.VIEW is 'thread' and Conf['Reply Pruning'] - @active = not (Conf['Quote Threading'] and Conf['Thread Quotes']) - @container = $.frag() @summary = $.el 'span', @@ -14,7 +12,7 @@ ReplyPruning = @inputs.enabled.checked = !@inputs.enabled.checked $.event 'change', null, @inputs.enabled - label = UI.checkbox 'Prune Replies', 'Show Last', @active + label = UI.checkbox 'Prune Replies', 'Show Last', Conf['Prune by Default'] el = $.el 'span', title: 'Maximum number of replies to show.' , @@ -25,6 +23,7 @@ ReplyPruning = enabled: label.firstElementChild replies: el.lastElementChild + @setEnabled.call @inputs.enabled $.on @inputs.enabled, 'change', @setEnabled $.on @inputs.replies, 'change', $.cb.value @@ -63,11 +62,10 @@ ReplyPruning = (ReplyPruning.totalFiles++ if post.file) # If we're linked to a post that we would hide, don't hide the posts in the first place. - # Also don't hide posts if we open the thread by a link to the OP. if ( ReplyPruning.active and /^#p\d+$/.test(location.hash) and - 0 <= @posts.keys.indexOf(location.hash[2..]) < 1 + Math.max(ReplyPruning.total - +Conf["Max Replies"], 0) + 1 <= @posts.keys.indexOf(location.hash[2..]) < 1 + Math.max(ReplyPruning.total - +Conf["Max Replies"], 0) ) ReplyPruning.active = ReplyPruning.inputs.enabled.checked = false diff --git a/src/Quotelinks/QuoteThreading.coffee b/src/Quotelinks/QuoteThreading.coffee index feb9ed80f..d032d7621 100644 --- a/src/Quotelinks/QuoteThreading.coffee +++ b/src/Quotelinks/QuoteThreading.coffee @@ -39,10 +39,12 @@ QuoteThreading = inserted: {} setEnabled: -> - other = ReplyPruning.inputs?.enabled - if @checked and other?.checked - other.checked = false - $.event 'change', null, other + if @checked + $.set 'Prune by Default', false + other = ReplyPruning.inputs?.enabled + if other?.checked + other.checked = false + $.event 'change', null, other $.cb.checked.call @ setThread: -> diff --git a/src/config/Config.coffee b/src/config/Config.coffee index 080b4c294..69291e027 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -409,6 +409,11 @@ Config = true 'Hide old replies in long threads. Number of replies shown can be set from header menu.' ] + 'Prune by Default': [ + false + 'Turn Reply Pruning on by default in all threads, except when navigating to a post that would be hidden.' + 1 + ] 'Posting and Captchas': 'Quick Reply': [