Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/dashboard/src/lib/use-github-revalidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ async function invalidatePullTabQueries(
}

await Promise.all(
queryKeys.map((queryKey) => queryClient.invalidateQueries({ queryKey })),
queryKeys.map((queryKey) =>
queryClient.invalidateQueries({ queryKey, refetchType: "all" }),
),
);
}

Expand All @@ -79,7 +81,9 @@ async function invalidateIssueTabQueries(
}

await Promise.all(
queryKeys.map((queryKey) => queryClient.invalidateQueries({ queryKey })),
queryKeys.map((queryKey) =>
queryClient.invalidateQueries({ queryKey, refetchType: "all" }),
),
);
}

Expand Down
22 changes: 20 additions & 2 deletions apps/dashboard/src/routes/_protected/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { GitPullRequestIcon, IssuesIcon, ReviewsIcon } from "@diffkit/icons";
import { useQuery } from "@tanstack/react-query";
import { createFileRoute, Link } from "@tanstack/react-router";
import type { ComponentType } from "react";
import { createFileRoute, Link, useRouter } from "@tanstack/react-router";
import { type ComponentType, useEffect } from "react";
import { DashboardContentLoading } from "#/components/layouts/dashboard-content-loading";
import { PullRequestRow } from "#/components/pulls/pull-request-row";
import {
githubMyIssuesQueryOptions,
githubMyPullsQueryOptions,
} from "#/lib/github.query";
import { preloadRouteOnce } from "#/lib/route-preload";
import { buildSeo, formatPageTitle } from "#/lib/seo";
import { useHasMounted } from "#/lib/use-has-mounted";

Expand Down Expand Up @@ -36,6 +37,7 @@ function OverviewPage() {
const { user } = Route.useRouteContext();
const scope = { userId: user.id };
const hasMounted = useHasMounted();
const router = useRouter();
const pullsQuery = useQuery({
...githubMyPullsQueryOptions(scope),
enabled: hasMounted,
Expand All @@ -45,6 +47,22 @@ function OverviewPage() {
enabled: hasMounted,
});

// Prefetch detail routes for recent PRs in the background so
// navigating into a PR is near-instant even without hovering first.
const authoredPulls = pullsQuery.data?.authored;
useEffect(() => {
if (!authoredPulls) return;
const recent = authoredPulls.slice(0, 10);
void Promise.allSettled(
recent.map((pr) =>
preloadRouteOnce(
router,
`/${pr.repository.owner}/${pr.repository.name}/pull/${pr.number}`,
),
),
);
}, [authoredPulls, router]);

if (pullsQuery.error) throw pullsQuery.error;
if (issuesQuery.error) throw issuesQuery.error;

Expand Down
Loading