refactor(web): simplify loader awaits with inline toPromise
Quentin Gliech
and
Claude Opus 4.6 (1M context)
created 1 month ago
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) <noreply@anthropic.com>
Change summary
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(-)
Detailed changes
@@ -61,8 +61,7 @@ export const Route = createFileRoute("/$repo/commit/$hash")({
const commitRef = preloadQuery<CommitQueryData>(COMMIT_QUERY, {
variables: { repo: repo === "_" ? null : repo, hash },
});
- await preloadQuery.toPromise(commitRef);
- return { commitRef };
+ return { commitRef: await preloadQuery.toPromise(commitRef) };
},
});
@@ -130,8 +130,7 @@ export const Route = createFileRoute("/$repo/")({
const refsRef = preloadQuery<RefsQueryData>(REFS_QUERY, {
variables: { repo: repo === "_" ? null : repo },
});
- await preloadQuery.toPromise(refsRef);
- return { refsRef };
+ return { refsRef: await preloadQuery.toPromise(refsRef) };
},
});
@@ -31,8 +31,10 @@ export const Route = createFileRoute("/$repo/issues/$id")({
const labelsRef = preloadQuery<ValidLabelsQuery>(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),
+ };
},
});
@@ -53,12 +53,11 @@ export const Route = createFileRoute("/$repo/issues/")({
const identitiesRef = preloadQuery<AllIdentitiesQuery>(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),
+ };
},
});
@@ -13,8 +13,7 @@ export const Route = createFileRoute("/")({
component: RouteComponent,
loader: async () => {
const repositoriesRef = preloadQuery<RepositoriesQuery>(RepositoriesDocument);
- await preloadQuery.toPromise(repositoriesRef);
- return { repositoriesRef };
+ return { repositoriesRef: await preloadQuery.toPromise(repositoriesRef) };
},
});