diff --git a/boards/static/js/thread_update.js b/boards/static/js/thread_update.js --- a/boards/static/js/thread_update.js +++ b/boards/static/js/thread_update.js @@ -138,7 +138,25 @@ function updatePost(postHtml) { type = POST_UPDATED; } else { - post.appendTo(threadBlock); + var postPubTime = new Date(post.find('time').attr('datetime')); + var allPosts = $('.post'); + var previousPost = null; + + allPosts.each(function(i) { + var curPost = $(this); + var curPostTime = new Date(curPost.find('time').attr('datetime')); + + if (i + 0 && curPostTime > postPubTime) { + previousPost = allPosts.get(i - 1); + return false; + }; + }); + + if (previousPost == null) { + previousPost = allPosts.last(); + } + + post.insertAfter(previousPost); if (bottom) { scrollToBottom();