# HG changeset patch # User neko259 # Date 2018-01-16 10:46:39 # Node ID 47f758c204c21a07887327d6f10fee725ecaeaeb # Parent cb363111231368bd1797598cf688c1724c0c862a Speed up post hiding, do not load the hidden posts list for each post being processed diff --git a/boards/static/js/main.js b/boards/static/js/main.js --- a/boards/static/js/main.js +++ b/boards/static/js/main.js @@ -143,11 +143,15 @@ function getHiddenPosts() { return arr; } -function processPostHiding(post) { +function processPostHiding(posts) { var hiddenPosts = getHiddenPosts(); - if (hiddenPosts.indexOf(post.attr("id")) > -1) { - post.toggleClass("hidden_post"); - } + + $.each(posts, function(index) { + var post = $(this); + if (hiddenPosts.indexOf(post.attr("id")) > -1) { + post.toggleClass("hidden_post"); + } + }); } /** @@ -158,7 +162,7 @@ function addScriptsToPost(post) { addRefLinkPreview(post[0]); highlightCode(post); processVolumeUser(post.find("video,audio")); - processPostHiding(post); + processPostHiding([post]); } /** @@ -354,7 +358,5 @@ function addContextMenu() { compatibilityCrutches(); - $('.post').each(function(index) { - processPostHiding($(this)); - }); + processPostHiding($('.post')); });