From b0ca427207d55d2bcb8e82f5cb7ecf0153088aa0 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 18 Jan 2014 14:11:36 -0700 Subject: [PATCH] Revert "Fix updating the context of threads and index" This reverts commit e7b1c52dbf9f25aec32bea64c712ee4075f7ef6f. --- builds/4chan-X.user.js | 29 +++++++++++++---------------- builds/crx/script.js | 29 +++++++++++++---------------- src/General/Index.coffee | 13 ++++++------- src/General/Navigate.coffee | 7 +++---- 4 files changed, 35 insertions(+), 43 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 1111bfe16..82b369bd0 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -2715,20 +2715,19 @@ Main.callbackNodes(Post, posts); return $.event('IndexRefresh'); }, - buildReplies: function(threads) { - var errors, posts; + buildReplies: function(threadRoots) { + var data, err, errors, i, lastReplies, node, nodes, post, posts, thread, threadRoot, _i, _j, _len, _len1; posts = []; - errors = null; - threads.forEach(function(thread) { - var data, err, i, lastReplies, node, nodes, post, threadRoot, _i, _len; - threadRoot = thread.OP.nodes.root.parentElement; + for (_i = 0, _len = threadRoots.length; _i < _len; _i++) { + threadRoot = threadRoots[_i]; + thread = Get.threadFromRoot(threadRoot); i = Index.liveThreadIDs.indexOf(thread.ID); if (!(lastReplies = Index.liveThreadData[i].last_replies)) { - return; + continue; } nodes = []; - for (_i = 0, _len = lastReplies.length; _i < _len; _i++) { - data = lastReplies[_i]; + for (_j = 0, _len1 = lastReplies.length; _j < _len1; _j++) { + data = lastReplies[_j]; if (post = thread.posts[data.no]) { nodes.push(post.nodes.root); continue; @@ -2747,8 +2746,8 @@ }); } } - return $.add(threadRoot, nodes); - }); + $.add(threadRoot, nodes); + } if (errors) { Main.handleErrors(errors); } @@ -2853,7 +2852,7 @@ $.rmAll(Index.root); $.rmAll(Header.hover); if (Conf['Show Replies']) { - Index.buildReplies(g.BOARD.threads); + Index.buildReplies(nodes); } return Index.buildStructure(nodes); }, @@ -12294,11 +12293,9 @@ pageNum = view; view = 'index'; } - if (view === g.VIEW && boardID === g.BOARD.ID) { - Navigate.updateContext(view); - } else { + Navigate.updateContext(view); + if (!(view === g.VIEW && boardID === g.BOARD.ID)) { Navigate.disconnect(); - Navigate.updateContext(view); Navigate.clean(); Navigate.reconnect(); } diff --git a/builds/crx/script.js b/builds/crx/script.js index 5712e0948..0b6a54afb 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -2725,20 +2725,19 @@ Main.callbackNodes(Post, posts); return $.event('IndexRefresh'); }, - buildReplies: function(threads) { - var errors, posts; + buildReplies: function(threadRoots) { + var data, err, errors, i, lastReplies, node, nodes, post, posts, thread, threadRoot, _i, _j, _len, _len1; posts = []; - errors = null; - threads.forEach(function(thread) { - var data, err, i, lastReplies, node, nodes, post, threadRoot, _i, _len; - threadRoot = thread.OP.nodes.root.parentElement; + for (_i = 0, _len = threadRoots.length; _i < _len; _i++) { + threadRoot = threadRoots[_i]; + thread = Get.threadFromRoot(threadRoot); i = Index.liveThreadIDs.indexOf(thread.ID); if (!(lastReplies = Index.liveThreadData[i].last_replies)) { - return; + continue; } nodes = []; - for (_i = 0, _len = lastReplies.length; _i < _len; _i++) { - data = lastReplies[_i]; + for (_j = 0, _len1 = lastReplies.length; _j < _len1; _j++) { + data = lastReplies[_j]; if (post = thread.posts[data.no]) { nodes.push(post.nodes.root); continue; @@ -2757,8 +2756,8 @@ }); } } - return $.add(threadRoot, nodes); - }); + $.add(threadRoot, nodes); + } if (errors) { Main.handleErrors(errors); } @@ -2863,7 +2862,7 @@ $.rmAll(Index.root); $.rmAll(Header.hover); if (Conf['Show Replies']) { - Index.buildReplies(g.BOARD.threads); + Index.buildReplies(nodes); } return Index.buildStructure(nodes); }, @@ -12283,11 +12282,9 @@ pageNum = view; view = 'index'; } - if (view === g.VIEW && boardID === g.BOARD.ID) { - Navigate.updateContext(view); - } else { + Navigate.updateContext(view); + if (!(view === g.VIEW && boardID === g.BOARD.ID)) { Navigate.disconnect(); - Navigate.updateContext(view); Navigate.clean(); Navigate.reconnect(); } diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 7936962de..5b72b1882 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -349,13 +349,12 @@ Index = Main.callbackNodes Post, posts $.event 'IndexRefresh' - buildReplies: (threads) -> - posts = [] - errors = null - threads.forEach (thread) -> - threadRoot = thread.OP.nodes.root.parentElement + buildReplies: (threadRoots) -> + posts = [] + for threadRoot in threadRoots + thread = Get.threadFromRoot threadRoot i = Index.liveThreadIDs.indexOf thread.ID - return unless lastReplies = Index.liveThreadData[i].last_replies + continue unless lastReplies = Index.liveThreadData[i].last_replies nodes = [] for data in lastReplies if post = thread.posts[data.no] @@ -437,7 +436,7 @@ Index = nodes.push target.data $.rmAll Index.root $.rmAll Header.hover - Index.buildReplies g.BOARD.threads if Conf['Show Replies'] + Index.buildReplies nodes if Conf['Show Replies'] Index.buildStructure nodes buildSinglePage: (pageNum) -> diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index e2d87ef7f..594cb8fe6 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -204,11 +204,10 @@ Navigate = pageNum = view view = 'index' # path is "/boardID/". See the problem? - if view is g.VIEW and boardID is g.BOARD.ID - Navigate.updateContext view - else # We've navigated somewhere we weren't before! + Navigate.updateContext view + + unless view is g.VIEW and boardID is g.BOARD.ID # We've navigated somewhere we weren't before! Navigate.disconnect() - Navigate.updateContext view Navigate.clean() Navigate.reconnect()