Fix error where we could have parsed the same post more than once because of multiple request callbacks.

This commit is contained in:
Nicolas Stepien 2012-09-05 03:33:51 +02:00
parent d3efc6347d
commit e0d73a64a7
2 changed files with 24 additions and 11 deletions

View File

@ -1404,8 +1404,12 @@
link.nextSibling.href = "/" + board + "/res/" + threadID + "#q" + postID; link.nextSibling.href = "/" + board + "/res/" + threadID + "#q" + postID;
inBoard = g.boards[board] || new Board(board); inBoard = g.boards[board] || new Board(board);
inThread = g.threads["" + board + "." + threadID] || new Thread(threadID, inBoard); inThread = g.threads["" + board + "." + threadID] || new Thread(threadID, inBoard);
post = new Post(pc, inThread, inBoard); if (!(post = g.posts["" + board + "." + postID])) {
post = new Post(postContainer, thread, board, {
isArchived: true
});
Main.callbackNodes(Post, [post]); Main.callbackNodes(Post, [post]);
}
if (!root.parentNode) { if (!root.parentNode) {
return; return;
} }
@ -1482,10 +1486,12 @@
}); });
board = g.boards[board] || new Board(board); board = g.boards[board] || new Board(board);
thread = g.threads["" + board + "." + threadID] || new Thread(threadID, board); thread = g.threads["" + board + "." + threadID] || new Thread(threadID, board);
if (!(post = g.posts["" + board + "." + postID])) {
post = new Post(postContainer, thread, board, { post = new Post(postContainer, thread, board, {
isArchived: true isArchived: true
}); });
Main.callbackNodes(Post, [post]); Main.callbackNodes(Post, [post]);
}
if (!root.parentNode) { if (!root.parentNode) {
return; return;
} }

View File

@ -1194,7 +1194,11 @@ Get =
new Board board new Board board
inThread = g.threads["#{board}.#{threadID}"] or inThread = g.threads["#{board}.#{threadID}"] or
new Thread threadID, inBoard new Thread threadID, inBoard
post = new Post pc, inThread, inBoard # In case of multiple callbacks for the same request,
# don't parse the same original post more than once.
unless post = g.posts["#{board}.#{postID}"]
post = new Post postContainer, thread, board,
isArchived: true
Main.callbackNodes Post, [post] Main.callbackNodes Post, [post]
# Stop here if the container has been removed while loading. # Stop here if the container has been removed while loading.
@ -1283,6 +1287,9 @@ Get =
new Board board new Board board
thread = g.threads["#{board}.#{threadID}"] or thread = g.threads["#{board}.#{threadID}"] or
new Thread threadID, board new Thread threadID, board
# In case of multiple callbacks for the same request,
# don't parse the same original post more than once.
unless post = g.posts["#{board}.#{postID}"]
post = new Post postContainer, thread, board, post = new Post postContainer, thread, board,
isArchived: true isArchived: true
Main.callbackNodes Post, [post] Main.callbackNodes Post, [post]