Skip to content

Commit 92491c3

Browse files
authored
Add loading spinners for uncached pages and fix UI polish issues (#48)
- Add pendingComponent to list routes (overview, pulls, issues, reviews) so a spinner shows while loaders fetch data on cold loads - Set defaultPendingMs: 0 on the router for instant pending UI - Simplify component loading fallbacks to show spinner during SSR-to-hydration gap - Prefetch viewer query in pull detail loader to prevent review-requested banner layout shift - Remove double border on review page resizable panel handle
1 parent 9efd223 commit 92491c3

7 files changed

Lines changed: 20 additions & 29 deletions

File tree

apps/dashboard/src/components/pulls/review/review-page.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,7 @@ export function ReviewPage() {
303303
</div>
304304

305305
<ResizablePanelGroup direction="horizontal" className="flex-1">
306-
<ResizablePanel
307-
defaultSize={20}
308-
minSize={12}
309-
maxSize={40}
310-
className="border-r"
311-
>
306+
<ResizablePanel defaultSize={20} minSize={12} maxSize={40}>
312307
<div className="flex h-full flex-col">
313308
<div className="px-3 py-2">
314309
<div className="relative flex items-center rounded-md border bg-surface-0 px-2.5 py-1.5">

apps/dashboard/src/router.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export function getRouter() {
1616
scrollRestoration: true,
1717
defaultPreload: "intent",
1818
defaultPreloadStaleTime: 0,
19+
defaultPendingMs: 0,
1920
Wrap: ({ children }) => (
2021
<AppQueryClientProvider queryClient={queryClient}>
2122
{children}

apps/dashboard/src/routes/_protected/$owner/$repo/pull.$pullId.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { createFileRoute } from "@tanstack/react-router";
22
import { PullDetailPage } from "#/components/pulls/detail/pull-detail-page";
3-
import { githubPullPageQueryOptions } from "#/lib/github.query";
3+
import {
4+
githubPullPageQueryOptions,
5+
githubViewerQueryOptions,
6+
} from "#/lib/github.query";
47
import { buildSeo, formatPageTitle, summarizeText } from "#/lib/seo";
58

69
export const Route = createFileRoute("/_protected/$owner/$repo/pull/$pullId")({
@@ -15,10 +18,15 @@ export const Route = createFileRoute("/_protected/$owner/$repo/pull/$pullId")({
1518

1619
const cachedData = context.queryClient.getQueryData(pageOptions.queryKey);
1720
if (cachedData !== undefined) {
21+
void context.queryClient.ensureQueryData(githubViewerQueryOptions(scope));
1822
return cachedData;
1923
}
2024

21-
return context.queryClient.ensureQueryData(pageOptions);
25+
const [pageData] = await Promise.all([
26+
context.queryClient.ensureQueryData(pageOptions),
27+
context.queryClient.ensureQueryData(githubViewerQueryOptions(scope)),
28+
]);
29+
return pageData;
2230
},
2331
head: ({ loaderData, match, params }) => {
2432
const pull = loaderData?.detail;

apps/dashboard/src/routes/_protected/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import { useHasMounted } from "#/lib/use-has-mounted";
1414
export const Route = createFileRoute("/_protected/")({
1515
loader: async ({ context }) => {
1616
const scope = { userId: context.user.id };
17-
1817
await Promise.all([
1918
context.queryClient.ensureQueryData(githubMyPullsQueryOptions(scope)),
2019
context.queryClient.ensureQueryData(githubMyIssuesQueryOptions(scope)),
2120
]);
2221
},
22+
pendingComponent: DashboardContentLoading,
2323
head: ({ match }) =>
2424
buildSeo({
2525
path: match.pathname,
@@ -110,11 +110,7 @@ function OverviewPage() {
110110
);
111111
}
112112

113-
if (hasMounted && (pullsQuery.isPending || issuesQuery.isPending)) {
114-
return <DashboardContentLoading />;
115-
}
116-
117-
return null;
113+
return <DashboardContentLoading />;
118114
}
119115

120116
type MetricCardProps = {

apps/dashboard/src/routes/_protected/issues.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const Route = createFileRoute("/_protected/issues")({
2323
githubMyIssuesQueryOptions(scope),
2424
);
2525
},
26+
pendingComponent: DashboardContentLoading,
2627
head: ({ match }) =>
2728
buildSeo({
2829
path: match.pathname,
@@ -113,11 +114,7 @@ function IssuesPage() {
113114
</div>
114115
);
115116
}
116-
if (hasMounted && query.isPending) {
117-
return <DashboardContentLoading />;
118-
}
119-
120-
return null;
117+
return <DashboardContentLoading />;
121118
}
122119

123120
type IssueGroupData = {

apps/dashboard/src/routes/_protected/pulls.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const Route = createFileRoute("/_protected/pulls")({
2727
const scope = { userId: context.user.id };
2828
await context.queryClient.ensureQueryData(githubMyPullsQueryOptions(scope));
2929
},
30+
pendingComponent: DashboardContentLoading,
3031
head: ({ match }) =>
3132
buildSeo({
3233
path: match.pathname,
@@ -135,11 +136,7 @@ function PullRequestsPage() {
135136
</div>
136137
);
137138
}
138-
if (hasMounted && query.isPending) {
139-
return <DashboardContentLoading />;
140-
}
141-
142-
return null;
139+
return <DashboardContentLoading />;
143140
}
144141

145142
type PullGroupData = {

apps/dashboard/src/routes/_protected/reviews.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const Route = createFileRoute("/_protected/reviews")({
1313
const scope = { userId: context.user.id };
1414
await context.queryClient.ensureQueryData(githubMyPullsQueryOptions(scope));
1515
},
16+
pendingComponent: DashboardContentLoading,
1617
head: ({ match }) =>
1718
buildSeo({
1819
path: match.pathname,
@@ -80,9 +81,5 @@ function ReviewsPage() {
8081
</div>
8182
);
8283
}
83-
if (hasMounted && query.isPending) {
84-
return <DashboardContentLoading />;
85-
}
86-
87-
return null;
84+
return <DashboardContentLoading />;
8885
}

0 commit comments

Comments
 (0)