diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 31c09ba8c..464001094 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -5030,35 +5030,26 @@ return true; }, toggle: function() { - var container, containers, node, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref; + var container, containers, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref; if (Conf['Unread Count']) { Unread.posts = new RandomAccessList; Unread.ready(); } thread = $('.thread'); replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread); - QuoteThreading.enabled = this.checked; - if (this.checked) { + if (QuoteThreading.enabled = this.checked) { QuoteThreading.hasRun = false; for (_i = 0, _len = replies.length; _i < _len; _i++) { reply = replies[_i]; - node = Get.postFromRoot(reply); - if (node.cb) { - node.cb(); - } else { - QuoteThreading.node.call(node); - if (node.cb) { - node.cb(); - } + post = Get.postFromRoot(reply); + if (post.cb) { + post.cb(); } } QuoteThreading.hasRun = true; } else { replies.sort(function(a, b) { - var aID, bID; - aID = Number(a.id.slice(2)); - bID = Number(b.id.slice(2)); - return aID - bID; + return Number(a.id.slice(2)) - Number(b.id.slice(2)); }); $.add(thread, replies); containers = $$('.threadContainer', thread); diff --git a/builds/crx/script.js b/builds/crx/script.js index 96890233e..c5ab8c091 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -5033,35 +5033,26 @@ return true; }, toggle: function() { - var container, containers, node, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref; + var container, containers, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref; if (Conf['Unread Count']) { Unread.posts = new RandomAccessList; Unread.ready(); } thread = $('.thread'); replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread); - QuoteThreading.enabled = this.checked; - if (this.checked) { + if (QuoteThreading.enabled = this.checked) { QuoteThreading.hasRun = false; for (_i = 0, _len = replies.length; _i < _len; _i++) { reply = replies[_i]; - node = Get.postFromRoot(reply); - if (node.cb) { - node.cb(); - } else { - QuoteThreading.node.call(node); - if (node.cb) { - node.cb(); - } + post = Get.postFromRoot(reply); + if (post.cb) { + post.cb(); } } QuoteThreading.hasRun = true; } else { replies.sort(function(a, b) { - var aID, bID; - aID = Number(a.id.slice(2)); - bID = Number(b.id.slice(2)); - return aID - bID; + return Number(a.id.slice(2)) - Number(b.id.slice(2)); }); $.add(thread, replies); containers = $$('.threadContainer', thread); diff --git a/src/Quotelinks/QuoteThreading.coffee b/src/Quotelinks/QuoteThreading.coffee index 575a7c5f8..ddc975dd0 100755 --- a/src/Quotelinks/QuoteThreading.coffee +++ b/src/Quotelinks/QuoteThreading.coffee @@ -28,7 +28,6 @@ QuoteThreading = $.off d, '4chanXInitFinished', QuoteThreading.setup post.cb() for ID, post of g.posts when post.cb - QuoteThreading.hasRun = true node: -> @@ -92,22 +91,19 @@ QuoteThreading = thread = $ '.thread' replies = $$ '.thread > .replyContainer, .threadContainer > .replyContainer', thread - QuoteThreading.enabled = @checked - if @checked + + if QuoteThreading.enabled = @checked QuoteThreading.hasRun = false for reply in replies - node = Get.postFromRoot reply - if node.cb - node.cb() - else - QuoteThreading.node.call node - node.cb() if node.cb + post = Get.postFromRoot reply + # QuoteThreading calculates whether or not posts should be threaded based on content + # and then threads them based on thread context, so regardless of whether or not it + # actually threads them all eligible posts WILL have a cb. Magic. + post.cb() if post.cb QuoteThreading.hasRun = true + else - replies.sort (a, b) -> - aID = Number a.id[2..] - bID = Number b.id[2..] - aID - bID + replies.sort (a, b) -> Number(a.id[2..]) - Number(b.id[2..]) $.add thread, replies containers = $$ '.threadContainer', thread $.rm container for container in containers