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])) {
Main.callbackNodes(Post, [post]); post = new Post(postContainer, thread, board, {
isArchived: true
});
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);
post = new Post(postContainer, thread, board, { if (!(post = g.posts["" + board + "." + postID])) {
isArchived: true post = new Post(postContainer, thread, board, {
}); isArchived: true
Main.callbackNodes(Post, [post]); });
Main.callbackNodes(Post, [post]);
}
if (!root.parentNode) { if (!root.parentNode) {
return; return;
} }

View File

@ -1194,8 +1194,12 @@ 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,
Main.callbackNodes Post, [post] # 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]
# Stop here if the container has been removed while loading. # Stop here if the container has been removed while loading.
return unless root.parentNode return unless root.parentNode
@ -1283,9 +1287,12 @@ 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
post = new Post postContainer, thread, board, # In case of multiple callbacks for the same request,
isArchived: true # don't parse the same original post more than once.
Main.callbackNodes Post, [post] unless post = g.posts["#{board}.#{postID}"]
post = new Post postContainer, thread, board,
isArchived: true
Main.callbackNodes Post, [post]
# Stop here if the container has been removed while loading. # Stop here if the container has been removed while loading.
return unless root.parentNode return unless root.parentNode