diff --git a/src/lib/router/definitions.ts b/src/lib/router/definitions.ts index f9517e94e..0da0558e1 100644 --- a/src/lib/router/definitions.ts +++ b/src/lib/router/definitions.ts @@ -50,8 +50,10 @@ export async function loadRoute( _previousLoaded: LoadedRoute, ): Promise { if (route.resource === "home") { - const repos: RepoInfo[] = await invoke("list_repos"); - const config: Config = await invoke("config"); + const [config, repos] = await Promise.all([ + invoke("config"), + invoke("list_repos"), + ]); return { resource: "home", params: { repos, config } }; } else if (route.resource === "repo.issue") { return loadIssue(route); diff --git a/src/views/repo/router.ts b/src/views/repo/router.ts index d9858a868..305de79c2 100644 --- a/src/views/repo/router.ts +++ b/src/views/repo/router.ts @@ -107,21 +107,23 @@ export type LoadedRepoRoute = export async function loadPatch( route: RepoPatchRoute, ): Promise { - const repo: RepoInfo = await invoke("repo_by_id", { - rid: route.rid, - }); - const config: Config = await invoke("config"); - const patches: PaginatedQuery = await invoke("list_patches", { - rid: route.rid, - }); - const patch: Patch = await invoke("patch_by_id", { - rid: route.rid, - id: route.patch, - }); - const revisions: Revision[] = await invoke("revisions_by_patch", { - rid: route.rid, - id: route.patch, - }); + const [config, repo, patches, patch, revisions] = await Promise.all([ + invoke("config"), + invoke("repo_by_id", { + rid: route.rid, + }), + invoke>("list_patches", { + rid: route.rid, + }), + invoke("patch_by_id", { + rid: route.rid, + id: route.patch, + }), + invoke("revisions_by_patch", { + rid: route.rid, + id: route.patch, + }), + ]); return { resource: "repo.patch", @@ -132,14 +134,16 @@ export async function loadPatch( export async function loadPatches( route: RepoPatchesRoute, ): Promise { - const repo: RepoInfo = await invoke("repo_by_id", { - rid: route.rid, - }); - const config: Config = await invoke("config"); - const patches: PaginatedQuery = await invoke("list_patches", { - rid: route.rid, - status: route.status, - }); + const [config, repo, patches] = await Promise.all([ + invoke("config"), + invoke("repo_by_id", { + rid: route.rid, + }), + invoke>("list_patches", { + rid: route.rid, + status: route.status, + }), + ]); return { resource: "repo.patches", @@ -150,14 +154,16 @@ export async function loadPatches( export async function loadCreateIssue( route: RepoCreateIssueRoute, ): Promise { - const repo: RepoInfo = await invoke("repo_by_id", { - rid: route.rid, - }); - const config: Config = await invoke("config"); - const issues: Issue[] = await invoke("list_issues", { - rid: route.rid, - status: "all", - }); + const [config, repo, issues] = await Promise.all([ + invoke("config"), + invoke("repo_by_id", { + rid: route.rid, + }), + invoke("list_issues", { + rid: route.rid, + status: "all", + }), + ]); return { resource: "repo.createIssue", @@ -168,18 +174,20 @@ export async function loadCreateIssue( export async function loadIssue( route: RepoIssueRoute, ): Promise { - const repo: RepoInfo = await invoke("repo_by_id", { - rid: route.rid, - }); - const config: Config = await invoke("config"); - const issues: Issue[] = await invoke("list_issues", { - rid: route.rid, - status: "all", - }); - const issue: Issue = await invoke("issue_by_id", { - rid: route.rid, - id: route.issue, - }); + const [config, repo, issue, issues] = await Promise.all([ + invoke("config"), + invoke("repo_by_id", { + rid: route.rid, + }), + invoke("issue_by_id", { + rid: route.rid, + id: route.issue, + }), + invoke("list_issues", { + rid: route.rid, + status: "all", + }), + ]); return { resource: "repo.issue", @@ -190,14 +198,16 @@ export async function loadIssue( export async function loadIssues( route: RepoIssuesRoute, ): Promise { - const repo: RepoInfo = await invoke("repo_by_id", { - rid: route.rid, - }); - const config: Config = await invoke("config"); - const issues: Issue[] = await invoke("list_issues", { - rid: route.rid, - status: route.status, - }); + const [config, repo, issues] = await Promise.all([ + invoke("config"), + invoke("repo_by_id", { + rid: route.rid, + }), + invoke("list_issues", { + rid: route.rid, + status: route.status, + }), + ]); return { resource: "repo.issues",