Make fetches concurrent

This commit is contained in:
Lim Chee Aun 2022-12-23 12:30:49 +08:00
parent fe78ac5fa0
commit a2e55eca90

View file

@ -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) => {