From a2e55eca90f9e4829e7a1738ace0393bed96f87f Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 23 Dec 2022 12:30:49 +0800 Subject: [PATCH] Make fetches concurrent --- src/pages/status.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/status.jsx b/src/pages/status.jsx index aef35975..d14c81c6 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -67,10 +67,13 @@ function StatusPage({ id }) { } (async () => { + const heroFetch = masto.statuses.fetch(id); + const contextFetch = masto.statuses.fetchContext(id); + const hasStatus = snapStates.statuses.has(id); let heroStatus = snapStates.statuses.get(id); try { - heroStatus = await masto.statuses.fetch(id); + heroStatus = await heroFetch; states.statuses.set(id, heroStatus); } catch (e) { // Silent fail if status is cached @@ -82,7 +85,7 @@ function StatusPage({ id }) { } try { - const context = await masto.statuses.fetchContext(id); + const context = await contextFetch; const { ancestors, descendants } = context; ancestors.forEach((status) => {