Skip to content

Commit 20e19a6

Browse files
authored
Merge pull request #19 from database-playground/next-16
Upgrade to Next.js 16
2 parents ca6d2ac + 9b5fce3 commit 20e19a6

File tree

8 files changed

+1093
-1989
lines changed

8 files changed

+1093
-1989
lines changed

app/(app)/layout.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@ import AppShell from "@/components/app-shell";
22
import DynamicPostHogIdentifier from "@/providers/posthog-identifier.dynamic";
33
import AuthorizedApolloWrapper from "@/providers/use-apollo.rsc";
44
import ProtectedRoute from "@/providers/use-protected-route";
5-
import { unstable_ViewTransition as ViewTransition } from "react";
5+
import { Suspense, ViewTransition } from "react";
66

77
export default function Layout({ children }: { children: React.ReactNode }) {
88
return (
9-
<ProtectedRoute>
10-
<AuthorizedApolloWrapper>
11-
<AppShell>
12-
<div className="mx-auto w-full max-w-7xl flex-1 p-3">
13-
<ViewTransition name="app-content">
14-
<div suppressHydrationWarning>{children}</div>
15-
</ViewTransition>
16-
</div>
17-
</AppShell>
18-
<DynamicPostHogIdentifier />
19-
</AuthorizedApolloWrapper>
20-
</ProtectedRoute>
9+
<Suspense>
10+
<ProtectedRoute>
11+
<AuthorizedApolloWrapper>
12+
<AppShell>
13+
<div className="mx-auto w-full max-w-7xl flex-1 p-3">
14+
<ViewTransition name="app-content">
15+
<div suppressHydrationWarning>{children}</div>
16+
</ViewTransition>
17+
</div>
18+
</AppShell>
19+
<DynamicPostHogIdentifier />
20+
</AuthorizedApolloWrapper>
21+
</ProtectedRoute>
22+
</Suspense>
2123
);
2224
}

app/login/_components/do-you-know/index.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ import { connection } from "next/server";
55
export default async function DoYouKnow() {
66
await connection();
77

8+
const randomKnow = await getDoYouKnow();
9+
10+
return (
11+
<div className="flex flex-col justify-center gap-2 text-center">
12+
<div className="text-sm text-gray-500">你知道嗎?</div>
13+
<div className="font-normal">{randomKnow}</div>
14+
</div>
15+
);
16+
}
17+
18+
export async function getDoYouKnow() {
819
const knowsList = [
920
<p key="do-you-knows-daily-login">
1021
每天登入可以獲得 20 點點數,<br />連續 7 天登入可以獲得 50 點加成!
@@ -21,10 +32,6 @@ export default async function DoYouKnow() {
2132
];
2233

2334
const randomKnow = knowsList[Math.floor(Math.random() * knowsList.length)];
24-
return (
25-
<div className="flex flex-col justify-center gap-2 text-center">
26-
<div className="text-sm text-gray-500">你知道嗎?</div>
27-
<div className="font-normal">{randomKnow}</div>
28-
</div>
29-
);
35+
36+
return randomKnow;
3037
}

app/login/_components/status/action.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
"use server";
22

33
import buildUri from "@/lib/build-uri";
4+
import { unstable_cacheLife as cacheLife } from "next/cache";
45

56
export async function getUpstreamLatency(): Promise<number> {
7+
"use cache";
8+
cacheLife("minutes");
9+
610
try {
7-
const start = Date.now();
11+
const start = performance.now();
812

9-
const response = await fetch(buildUri("/"), {
10-
next: {
11-
revalidate: 120, // update latency every 2 minutes
12-
},
13-
});
13+
const response = await fetch(buildUri("/"));
1414
if (!response.ok) {
1515
return -1;
1616
}
1717

18-
return Date.now() - start;
18+
return Math.round(performance.now() - start);
1919
} catch (error) {
2020
console.error("Error getting upstream status:", error);
2121
return -1;

0 commit comments

Comments
 (0)