From 6ce96d7b5c9b45877c0090ca00720b6b5c0804a2 Mon Sep 17 00:00:00 2001 From: fatchan Date: Fri, 5 Jul 2019 22:17:38 +0000 Subject: [PATCH] post re-markups with Promise.all --- models/forms/deletepost.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/models/forms/deletepost.js b/models/forms/deletepost.js index e5241427..3cc34ad6 100644 --- a/models/forms/deletepost.js +++ b/models/forms/deletepost.js @@ -116,10 +116,9 @@ module.exports = async (posts, board) => { //get posts that quoted deleted posts so we can remarkup them if (backlinkRebuilds.size > 0) { const remarkupPosts = await Posts.globalGetPosts([...backlinkRebuilds]); - for (let i = 0; i < remarkupPosts.length; i++) { - const post = remarkupPosts[i]; - if (post.nomarkup && post.nomarkup.length > 0) { - //if the post had a message, redo the markup + await Promise.all(remarkupPosts.map(async post => { //doing these all at once + if (post.nomarkup && post.nomarkup.length > 0) { //is this check even necessary? how would it have a quote with no message + //redo the markup let message = simpleMarkdown(post.nomarkup); const { quotedMessage, threadQuotes } = await linkQuotes(post.board, post.nomarkup, post.thread); message = sanitize(quotedMessage, sanitizeOptions); @@ -137,7 +136,7 @@ module.exports = async (posts, board) => { } }); } - } + })); } //bulkwrite it all