diff --git a/boards/static/js/thread.js b/boards/static/js/thread.js --- a/boards/static/js/thread.js +++ b/boards/static/js/thread.js @@ -58,7 +58,7 @@ function addQuickReply(postId) { // If this is not OP, add reflink to the post. If there already is // the same reflink, don't add it again. - if (!post.is(':first-child') && !textAreaJq.val().contains(postLinkRaw)) { + if (!post.is(':first-child') && textAreaJq.val().indexOf(postLinkRaw) < 0) { textToAdd += postLinkRaw + '\n'; } 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 @@ -23,13 +23,15 @@ for the JavaScript code in this page. */ +var CLASS_POST = '.post' + var wsUser = ''; var unreadPosts = 0; var documentOriginalTitle = ''; // Thread ID does not change, can be stored one time -var threadId = $('div.thread').children('.post').first().attr('id'); +var threadId = $('div.thread').children(CLASS_POST).first().attr('id'); /** * Connect to websocket server and subscribe to thread updates. On any update we @@ -97,6 +99,10 @@ function getThreadDiff() { hasMetaUpdates = true; } + var addedPostsCount = addedPosts.length; + updateBumplimitProgress(addedPostsCount); + showNewPostsTitle(addedPostsCount); + var updatedPosts = data.updated; for (var i = 0; i < updatedPosts.length; i++) { @@ -136,13 +142,7 @@ function updatePost(postHtml) { if (existingPosts.size() > 0) { existingPosts.replaceWith(post); } else { - var threadPosts = threadBlock.children('.post'); - var lastPost = threadPosts.last(); - - post.appendTo(lastPost.parent()); - - updateBumplimitProgress(1); - showNewPostsTitle(1); + post.appendTo(threadBlock); if (bottom) { scrollToBottom(); @@ -176,7 +176,7 @@ function initAutoupdate() { } function getReplyCount() { - return $('.thread').children('.post').length + return $('.thread').children(CLASS_POST).length } function getImageCount() {