1- import React from "react" ;
1+ import React , { useEffect , useRef , useState } from "react" ;
22import useResponsiveSize from "../utils/useResponsiveSize" ;
33import animationData from "../../src/animations/join_meeting.json" ;
44import Lottie from "react-lottie" ;
5+ import { Box } from "@material-ui/core" ;
56
67const WaitingToJoin = ( ) => {
8+ const waitingMessages = [
9+ { index : 0 , text : "Creating a room for you..." } ,
10+ { index : 1 , text : "Almost there..." } ,
11+ ] ;
12+ const [ message , setMessage ] = useState ( waitingMessages [ 0 ] ) ;
13+
14+ const intervalRef = useRef ( null ) ;
15+
16+ useEffect ( ( ) => {
17+ intervalRef . current = setInterval ( ( ) => {
18+ setMessage ( ( s ) =>
19+ s . index === waitingMessages . length - 1
20+ ? s
21+ : waitingMessages [ s . index + 1 ]
22+ ) ;
23+ } , 3000 ) ;
24+
25+ return ( ) => {
26+ clearInterval ( intervalRef . current ) ;
27+ } ;
28+ } , [ ] ) ;
29+
730 const lottieSize = useResponsiveSize ( {
8- xl : 500 ,
9- lg : 500 ,
10- md : 400 ,
31+ xl : 250 ,
32+ lg : 250 ,
33+ md : 200 ,
1134 sm : 200 ,
1235 xs : 180 ,
1336 } ) ;
@@ -30,12 +53,17 @@ const WaitingToJoin = () => {
3053 height : "100vh" ,
3154 } }
3255 >
33- < Lottie
34- options = { defaultOptions }
35- eventListeners = { [ { eventName : "done" } ] }
36- height = { lottieSize }
37- width = { lottieSize }
38- />
56+ < Box style = { { display : "flex" , flexDirection : "column" } } >
57+ < Lottie
58+ options = { defaultOptions }
59+ eventListeners = { [ { eventName : "done" } ] }
60+ height = { lottieSize }
61+ width = { lottieSize }
62+ />
63+ < h2 style = { { color : "white" , marginTop : 4 , textAlign : "center" } } >
64+ { message . text }
65+ </ h2 >
66+ </ Box >
3967 </ div >
4068 ) ;
4169} ;
0 commit comments