From 7cb78fc876ecb42502dafe7e7ed717c151c303ae Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Sun, 29 Mar 2026 21:40:45 +0200 Subject: [PATCH] refactor(web): simplify loader awaits with inline toPromise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit replace Promise.all + separate return with sequential await in the return object — preloadQuery() calls already fire in parallel, so awaiting them inline is equivalent but reads cleaner Co-Authored-By: Claude Opus 4.6 (1M context) --- webui2/src/routes/$repo/commit/$hash.tsx | 3 +-- webui2/src/routes/$repo/index.tsx | 3 +-- webui2/src/routes/$repo/issues/$id.tsx | 6 ++++-- webui2/src/routes/$repo/issues/index.tsx | 11 +++++------ webui2/src/routes/index.tsx | 3 +-- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/webui2/src/routes/$repo/commit/$hash.tsx b/webui2/src/routes/$repo/commit/$hash.tsx index 39015ca8e7c80efc84b13bfffd2c3fa832e44b91..4aafd19c179001607505562aeb9a5de63b2804f6 100644 --- a/webui2/src/routes/$repo/commit/$hash.tsx +++ b/webui2/src/routes/$repo/commit/$hash.tsx @@ -61,8 +61,7 @@ export const Route = createFileRoute("/$repo/commit/$hash")({ const commitRef = preloadQuery(COMMIT_QUERY, { variables: { repo: repo === "_" ? null : repo, hash }, }); - await preloadQuery.toPromise(commitRef); - return { commitRef }; + return { commitRef: await preloadQuery.toPromise(commitRef) }; }, }); diff --git a/webui2/src/routes/$repo/index.tsx b/webui2/src/routes/$repo/index.tsx index e0e2afac57e35306b21894fa34a039e26a3880e5..96ea0aec4fa9f0f1cac2c4e7109b9c068fa20d59 100644 --- a/webui2/src/routes/$repo/index.tsx +++ b/webui2/src/routes/$repo/index.tsx @@ -130,8 +130,7 @@ export const Route = createFileRoute("/$repo/")({ const refsRef = preloadQuery(REFS_QUERY, { variables: { repo: repo === "_" ? null : repo }, }); - await preloadQuery.toPromise(refsRef); - return { refsRef }; + return { refsRef: await preloadQuery.toPromise(refsRef) }; }, }); diff --git a/webui2/src/routes/$repo/issues/$id.tsx b/webui2/src/routes/$repo/issues/$id.tsx index 2638a1f9b24c27a3321cd3321d18de1bce6e12d1..33b675e481f954388c3c1ad3e6005ae9189a3e55 100644 --- a/webui2/src/routes/$repo/issues/$id.tsx +++ b/webui2/src/routes/$repo/issues/$id.tsx @@ -31,8 +31,10 @@ export const Route = createFileRoute("/$repo/issues/$id")({ const labelsRef = preloadQuery(ValidLabelsDocument, { variables: { ref }, }); - await Promise.all([preloadQuery.toPromise(bugDetailRef), preloadQuery.toPromise(labelsRef)]); - return { bugDetailRef, labelsRef }; + return { + bugDetailRef: await preloadQuery.toPromise(bugDetailRef), + labelsRef: await preloadQuery.toPromise(labelsRef), + }; }, }); diff --git a/webui2/src/routes/$repo/issues/index.tsx b/webui2/src/routes/$repo/issues/index.tsx index d8ac588701159893d2cabbaf622b57df29503e9e..5e7c770df947fddfefd665e025eb7022553f23eb 100644 --- a/webui2/src/routes/$repo/issues/index.tsx +++ b/webui2/src/routes/$repo/issues/index.tsx @@ -53,12 +53,11 @@ export const Route = createFileRoute("/$repo/issues/")({ const identitiesRef = preloadQuery(AllIdentitiesDocument, { variables: { ref }, }); - await Promise.all([ - preloadQuery.toPromise(bugListRef), - preloadQuery.toPromise(labelsRef), - preloadQuery.toPromise(identitiesRef), - ]); - return { bugListRef, labelsRef, identitiesRef }; + return { + bugListRef: await preloadQuery.toPromise(bugListRef), + labelsRef: await preloadQuery.toPromise(labelsRef), + identitiesRef: await preloadQuery.toPromise(identitiesRef), + }; }, }); diff --git a/webui2/src/routes/index.tsx b/webui2/src/routes/index.tsx index 80c2a966c85bf024c38c9cb2e5dfbbe391073df4..e684a35c97fee6a824bb8766b3532d2cbf892e20 100644 --- a/webui2/src/routes/index.tsx +++ b/webui2/src/routes/index.tsx @@ -13,8 +13,7 @@ export const Route = createFileRoute("/")({ component: RouteComponent, loader: async () => { const repositoriesRef = preloadQuery(RepositoriesDocument); - await preloadQuery.toPromise(repositoriesRef); - return { repositoriesRef }; + return { repositoriesRef: await preloadQuery.toPromise(repositoriesRef) }; }, });