From 7c00e814b711712e5e7d092e1647987c829968ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 31 Jul 2025 09:00:40 -0400 Subject: [PATCH] refactor: use promise.all --- src/api/posts.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/posts.js b/src/api/posts.js index f41b6a66ea..3eda085dec 100644 --- a/src/api/posts.js +++ b/src/api/posts.js @@ -491,10 +491,12 @@ async function diffsPrivilegeCheck(pid, uid) { postsAPI.getDiffs = async (caller, data) => { await diffsPrivilegeCheck(data.pid, caller.uid); - const timestamps = await posts.diffs.list(data.pid); - const post = await posts.getPostFields(data.pid, ['timestamp', 'uid']); + const [timestamps, post, diffs] = await Promise.all([ + posts.diffs.list(data.pid), + posts.getPostFields(data.pid, ['timestamp', 'uid']), + posts.diffs.get(data.pid), + ]); - const diffs = await posts.diffs.get(data.pid); const uids = diffs.map(diff => diff.uid || null); uids.push(post.uid); let usernames = await user.getUsersFields(uids, ['username']);