Revert "Fix updating the context of threads and index"

This reverts commit e7b1c52dbf9f25aec32bea64c712ee4075f7ef6f.
This commit is contained in:
Zixaphir 2014-01-18 14:11:36 -07:00
parent e7b1c52dbf
commit b0ca427207
4 changed files with 35 additions and 43 deletions

View File

@ -2715,20 +2715,19 @@
Main.callbackNodes(Post, posts); Main.callbackNodes(Post, posts);
return $.event('IndexRefresh'); return $.event('IndexRefresh');
}, },
buildReplies: function(threads) { buildReplies: function(threadRoots) {
var errors, posts; var data, err, errors, i, lastReplies, node, nodes, post, posts, thread, threadRoot, _i, _j, _len, _len1;
posts = []; posts = [];
errors = null; for (_i = 0, _len = threadRoots.length; _i < _len; _i++) {
threads.forEach(function(thread) { threadRoot = threadRoots[_i];
var data, err, i, lastReplies, node, nodes, post, threadRoot, _i, _len; thread = Get.threadFromRoot(threadRoot);
threadRoot = thread.OP.nodes.root.parentElement;
i = Index.liveThreadIDs.indexOf(thread.ID); i = Index.liveThreadIDs.indexOf(thread.ID);
if (!(lastReplies = Index.liveThreadData[i].last_replies)) { if (!(lastReplies = Index.liveThreadData[i].last_replies)) {
return; continue;
} }
nodes = []; nodes = [];
for (_i = 0, _len = lastReplies.length; _i < _len; _i++) { for (_j = 0, _len1 = lastReplies.length; _j < _len1; _j++) {
data = lastReplies[_i]; data = lastReplies[_j];
if (post = thread.posts[data.no]) { if (post = thread.posts[data.no]) {
nodes.push(post.nodes.root); nodes.push(post.nodes.root);
continue; continue;
@ -2747,8 +2746,8 @@
}); });
} }
} }
return $.add(threadRoot, nodes); $.add(threadRoot, nodes);
}); }
if (errors) { if (errors) {
Main.handleErrors(errors); Main.handleErrors(errors);
} }
@ -2853,7 +2852,7 @@
$.rmAll(Index.root); $.rmAll(Index.root);
$.rmAll(Header.hover); $.rmAll(Header.hover);
if (Conf['Show Replies']) { if (Conf['Show Replies']) {
Index.buildReplies(g.BOARD.threads); Index.buildReplies(nodes);
} }
return Index.buildStructure(nodes); return Index.buildStructure(nodes);
}, },
@ -12294,11 +12293,9 @@
pageNum = view; pageNum = view;
view = 'index'; view = 'index';
} }
if (view === g.VIEW && boardID === g.BOARD.ID) { Navigate.updateContext(view);
Navigate.updateContext(view); if (!(view === g.VIEW && boardID === g.BOARD.ID)) {
} else {
Navigate.disconnect(); Navigate.disconnect();
Navigate.updateContext(view);
Navigate.clean(); Navigate.clean();
Navigate.reconnect(); Navigate.reconnect();
} }

View File

@ -2725,20 +2725,19 @@
Main.callbackNodes(Post, posts); Main.callbackNodes(Post, posts);
return $.event('IndexRefresh'); return $.event('IndexRefresh');
}, },
buildReplies: function(threads) { buildReplies: function(threadRoots) {
var errors, posts; var data, err, errors, i, lastReplies, node, nodes, post, posts, thread, threadRoot, _i, _j, _len, _len1;
posts = []; posts = [];
errors = null; for (_i = 0, _len = threadRoots.length; _i < _len; _i++) {
threads.forEach(function(thread) { threadRoot = threadRoots[_i];
var data, err, i, lastReplies, node, nodes, post, threadRoot, _i, _len; thread = Get.threadFromRoot(threadRoot);
threadRoot = thread.OP.nodes.root.parentElement;
i = Index.liveThreadIDs.indexOf(thread.ID); i = Index.liveThreadIDs.indexOf(thread.ID);
if (!(lastReplies = Index.liveThreadData[i].last_replies)) { if (!(lastReplies = Index.liveThreadData[i].last_replies)) {
return; continue;
} }
nodes = []; nodes = [];
for (_i = 0, _len = lastReplies.length; _i < _len; _i++) { for (_j = 0, _len1 = lastReplies.length; _j < _len1; _j++) {
data = lastReplies[_i]; data = lastReplies[_j];
if (post = thread.posts[data.no]) { if (post = thread.posts[data.no]) {
nodes.push(post.nodes.root); nodes.push(post.nodes.root);
continue; continue;
@ -2757,8 +2756,8 @@
}); });
} }
} }
return $.add(threadRoot, nodes); $.add(threadRoot, nodes);
}); }
if (errors) { if (errors) {
Main.handleErrors(errors); Main.handleErrors(errors);
} }
@ -2863,7 +2862,7 @@
$.rmAll(Index.root); $.rmAll(Index.root);
$.rmAll(Header.hover); $.rmAll(Header.hover);
if (Conf['Show Replies']) { if (Conf['Show Replies']) {
Index.buildReplies(g.BOARD.threads); Index.buildReplies(nodes);
} }
return Index.buildStructure(nodes); return Index.buildStructure(nodes);
}, },
@ -12283,11 +12282,9 @@
pageNum = view; pageNum = view;
view = 'index'; view = 'index';
} }
if (view === g.VIEW && boardID === g.BOARD.ID) { Navigate.updateContext(view);
Navigate.updateContext(view); if (!(view === g.VIEW && boardID === g.BOARD.ID)) {
} else {
Navigate.disconnect(); Navigate.disconnect();
Navigate.updateContext(view);
Navigate.clean(); Navigate.clean();
Navigate.reconnect(); Navigate.reconnect();
} }

View File

@ -349,13 +349,12 @@ Index =
Main.callbackNodes Post, posts Main.callbackNodes Post, posts
$.event 'IndexRefresh' $.event 'IndexRefresh'
buildReplies: (threads) -> buildReplies: (threadRoots) ->
posts = [] posts = []
errors = null for threadRoot in threadRoots
threads.forEach (thread) -> thread = Get.threadFromRoot threadRoot
threadRoot = thread.OP.nodes.root.parentElement
i = Index.liveThreadIDs.indexOf thread.ID i = Index.liveThreadIDs.indexOf thread.ID
return unless lastReplies = Index.liveThreadData[i].last_replies continue unless lastReplies = Index.liveThreadData[i].last_replies
nodes = [] nodes = []
for data in lastReplies for data in lastReplies
if post = thread.posts[data.no] if post = thread.posts[data.no]
@ -437,7 +436,7 @@ Index =
nodes.push target.data nodes.push target.data
$.rmAll Index.root $.rmAll Index.root
$.rmAll Header.hover $.rmAll Header.hover
Index.buildReplies g.BOARD.threads if Conf['Show Replies'] Index.buildReplies nodes if Conf['Show Replies']
Index.buildStructure nodes Index.buildStructure nodes
buildSinglePage: (pageNum) -> buildSinglePage: (pageNum) ->

View File

@ -204,11 +204,10 @@ Navigate =
pageNum = view pageNum = view
view = 'index' # path is "/boardID/". See the problem? view = 'index' # path is "/boardID/". See the problem?
if view is g.VIEW and boardID is g.BOARD.ID Navigate.updateContext view
Navigate.updateContext view
else # We've navigated somewhere we weren't before! unless view is g.VIEW and boardID is g.BOARD.ID # We've navigated somewhere we weren't before!
Navigate.disconnect() Navigate.disconnect()
Navigate.updateContext view
Navigate.clean() Navigate.clean()
Navigate.reconnect() Navigate.reconnect()