# HG changeset patch # User neko259 # Date 2018-05-28 07:39:32 # Node ID fd2a304e7e47c476d0dd88a6f7683b9bc4febbf8 # Parent 2e6f7c21e797136c7437f929cf880548c3be0a59 Insert new posts in the pub time position instead of the end (js). Used when the posts are synced to the middle of the thread 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();