File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -4,23 +4,33 @@ import Link from "next/link";
44import { useEffect , useState } from "react" ;
55import * as chat from "~/api/chat/chat" ;
66import { RoomWindow } from "~/components/chat/RoomWindow" ;
7+ import FullScreenCircularProgress from "~/components/common/FullScreenCircularProgress" ;
78
89export 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" >
You can’t perform that action at this time.
0 commit comments