# HG changeset patch # User neko259 # Date 2015-04-01 15:56:39 # Node ID 5583a4cbf3a53917825d44f9f6d261e0534c79c6 # Parent 8518d2580b4a5c74ad97232593ff9f7af2571548 Update metadata panel only once when a multiple of posts in updated during getting thread diff 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 @@ -104,6 +104,8 @@ function getThreadDiff() { updatePost(post) } + updateMetadataPanel(); + // TODO Process removed posts if any $('.metapanel').attr('data-last-update', data.last_update); }) @@ -121,8 +123,6 @@ function updatePost(postHtml) { var threadBlock = $('div.thread'); - var lastUpdate = ''; - var postId = post.attr('id'); // If the post already exists, replace it. Otherwise add as a new one. @@ -139,16 +139,12 @@ function updatePost(postHtml) { updateBumplimitProgress(1); showNewPostsTitle(1); - lastUpdate = post.children('.post-info').first() - .children('.pub_time').first().html(); - if (bottom) { scrollToBottom(); } } processNewPost(post); - updateMetadataPanel(lastUpdate) } /** @@ -186,13 +182,15 @@ function getImageCount() { * Update post count, images count and last update time in the metadata * panel. */ -function updateMetadataPanel(lastUpdate) { +function updateMetadataPanel() { var replyCountField = $('#reply-count'); var imageCountField = $('#image-count'); replyCountField.text(getReplyCount()); imageCountField.text(getImageCount()); + var lastUpdate = $('.post:last').children('.post-info').first() + .children('.pub_time').first().html(); if (lastUpdate !== '') { var lastUpdateField = $('#last-update'); lastUpdateField.html(lastUpdate);