···
1
1
+
import { WalkingLoading } from "../../WalkingLoading";
2
2
+
3
3
+
export default function Loading() {
4
4
+
return <WalkingLoading />;
5
5
+
}
···
1
1
import { HomeShell } from "../HomeShell";
2
2
3
3
+
export const instant = false;
4
4
+
3
5
export default async function HomeLayout({ children }: { children: React.ReactNode }) {
4
6
return <HomeShell>{children}</HomeShell>;
5
7
}
···
3
3
import { createContext, useContext, ReactNode } from "react";
4
4
5
5
type AuthContextType = {
6
6
-
did: string | null;
6
6
+
didPromise: Promise<string | null>;
7
7
};
8
8
9
9
const AuthContext = createContext<AuthContextType | null>(null);
10
10
11
11
-
export function AuthProvider({ children, did }: { children: ReactNode; did: string | null }) {
12
12
-
return <AuthContext.Provider value={{ did }}>{children}</AuthContext.Provider>;
11
11
+
export function AuthProvider({
12
12
+
children,
13
13
+
didPromise,
14
14
+
}: {
15
15
+
children: ReactNode;
16
16
+
didPromise: Promise<string | null>;
17
17
+
}) {
18
18
+
return <AuthContext.Provider value={{ didPromise }}>{children}</AuthContext.Provider>;
13
19
}
14
20
15
21
export function useAuthContext() {
···
1
1
"use client";
2
2
3
3
+
import { Suspense } from "react";
3
4
import { useSelectedLayoutSegment } from "next/navigation";
4
5
import Link, { useLinkStatus } from "next/link";
5
6
import "./SegmentTabs.css";
···
38
39
}
39
40
40
41
export function SegmentTabs({ segments, basePath = "/" }: SegmentTabsProps) {
42
42
+
return (
43
43
+
<Suspense fallback={<SegmentTabsShim segments={segments} basePath={basePath} />}>
44
44
+
<SegmentTabsLoaded segments={segments} basePath={basePath} />
45
45
+
</Suspense>
46
46
+
);
47
47
+
}
48
48
+
49
49
+
export function SegmentTabsShim({ segments, basePath }: SegmentTabsProps) {
50
50
+
return <SegmentTabsBase selected={null} segments={segments} basePath={basePath} />;
51
51
+
}
52
52
+
53
53
+
export function SegmentTabsLoaded({ segments, basePath }: SegmentTabsProps) {
41
54
const selected = useSelectedLayoutSegment();
55
55
+
return <SegmentTabsBase selected={selected} segments={segments} basePath={basePath} />;
56
56
+
}
57
57
+
58
58
+
export function SegmentTabsBase({
59
59
+
segments,
60
60
+
basePath,
61
61
+
selected,
62
62
+
}: SegmentTabsProps & { selected: string | null }) {
42
63
return (
43
64
<nav className="SegmentTabs">
44
65
{segments.map((segment) => {
···
10
10
}>;
11
11
};
12
12
13
13
+
export const instant = false;
14
14
+
13
15
function decodeHandle(rawHandle: string): string {
14
16
return decodeURIComponent(rawHandle);
15
17
}
···
1
1
+
import { TrailsLoading } from "../../../TrailsLoading";
2
2
+
3
3
+
export default function Loading() {
4
4
+
return <TrailsLoading />;
5
5
+
}
···
1
1
import { ProfileShell } from "./ProfileShell";
2
2
3
3
+
export const instant = false;
4
4
+
3
5
export default function ProfileLayout({
4
6
children,
5
7
params,
···
3
3
import { LoginModalProvider } from "@/app/LoginModalContext";
4
4
import { LoginModal } from "@/app/LoginModal";
5
5
import { loadCurrentDid } from "@/data/queries";
6
6
-
import { Suspense } from "react";
7
6
import { AuthProvider } from "@/app/AuthContext";
8
7
export const metadata: Metadata = {
9
8
metadataBase: new URL("https://sidetrail.app"),
···
15
14
return (
16
15
<html lang="en">
17
16
<body>
18
18
-
<Suspense fallback={null}>
19
19
-
<Auth>
20
20
-
<LoginModalProvider>
21
21
-
{children}
22
22
-
<LoginModal />
23
23
-
</LoginModalProvider>
24
24
-
</Auth>
25
25
-
</Suspense>
17
17
+
<Auth>
18
18
+
<LoginModalProvider>
19
19
+
{children}
20
20
+
<LoginModal />
21
21
+
</LoginModalProvider>
22
22
+
</Auth>
26
23
</body>
27
24
</html>
28
25
);
29
26
}
30
27
31
28
async function Auth({ children }: { children: React.ReactNode }) {
32
32
-
const did = await loadCurrentDid();
33
33
-
return <AuthProvider did={did}>{children}</AuthProvider>;
29
29
+
const didPromise = loadCurrentDid();
30
30
+
return <AuthProvider didPromise={didPromise}>{children}</AuthProvider>;
34
31
}
···
5
5
6
6
export function useAuthAction() {
7
7
const { openLoginModal } = useLoginModal();
8
8
-
const { did } = useAuthContext();
8
8
+
const { didPromise } = useAuthContext();
9
9
10
10
return <Args extends unknown[], R>(action: (...args: Args) => Promise<R>) =>
11
11
async (...args: Args): Promise<R | undefined> => {
12
12
+
const did = await didPromise;
12
13
if (did) {
13
14
return action(...args);
14
15
} else {