Skip to content

Commit c280768

Browse files
committed
DMのロード時にエラーが表示されないようにした
1 parent 3156590 commit c280768

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

web/app/chat/[id]/page.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,33 @@ import Link from "next/link";
44
import { useEffect, useState } from "react";
55
import * as chat from "~/api/chat/chat";
66
import { RoomWindow } from "~/components/chat/RoomWindow";
7+
import FullScreenCircularProgress from "~/components/common/FullScreenCircularProgress";
78

89
export default function Page({ params }: { params: { id: string } }) {
910
const id = Number.parseInt(params.id);
1011
const [room, setRoom] = useState<(DMRoom & PersonalizedDMRoom) | null>(null);
12+
const [loading, setLoading] = useState(true);
13+
1114
useEffect(() => {
1215
(async () => {
13-
const room = await chat.getDM(id);
14-
setRoom(room);
16+
try {
17+
const room = await chat.getDM(id);
18+
setRoom(room);
19+
} finally {
20+
setLoading(false);
21+
}
1522
})();
1623
}, [id]);
1724

25+
if (loading) {
26+
return <FullScreenCircularProgress />;
27+
}
28+
1829
return (
1930
<>
2031
{room ? (
2132
<RoomWindow friendId={id} room={room} />
2233
) : (
23-
// FIXME: this isn't an error when it's just loading
2434
<p>
2535
Sorry, an unexpected error has occurred.
2636
<Link href="/home" className="text-blue-600">

0 commit comments

Comments
 (0)