@@ -18,11 +18,9 @@ import { Icon } from '@iconify/react';
1818import eraser24Filled from '@iconify/icons-fluent/eraser-24-filled' ;
1919import penFill from '@iconify/icons-bi/pen-fill' ;
2020import 'react-circular-progressbar/dist/styles.css' ;
21- import { v4 as uuidV4 } from 'uuid' ;
2221
2322
24- export default function IDE ( { modal, toggleModal, python, setpython, input, setInput, selected, setSelected, output, textEditor, setTextEditor, processing, percentageStage } ) {
25- const [ DocId , setDocId ] = useState ( null ) ;
23+ export default function IDE ( { docId, modal, toggleModal, python, setpython, input, setInput, selected, setSelected, output, textEditor, setTextEditor, processing, percentageStage } ) {
2624 const [ socket , setSocket ] = useState ( null ) ;
2725 const [ cpp , setcpp ] = useState ( '' ) ;
2826 const [ java , setjava ] = useState ( '' ) ;
@@ -42,14 +40,6 @@ export default function IDE({ modal, toggleModal, python, setpython, input, setI
4240
4341
4442 useEffect ( ( ) => {
45- if ( window . location . pathname === "/" ) {
46- const uid = uuidV4 ( )
47- setDocId ( uid )
48- window . location . href = "/" + uid
49- }
50- else {
51- setDocId ( window . location . pathname . split ( '/' ) [ 1 ] )
52- }
5343 var TempSocket = io ( process . env . REACT_APP_BACKEND_ENDPOINT_URL ) ;
5444 setSocket ( TempSocket ) ;
5545 const peer = new Peer ( undefined , {
@@ -67,14 +57,14 @@ export default function IDE({ modal, toggleModal, python, setpython, input, setI
6757
6858 useEffect ( ( ) => {
6959 if ( socket == null ) return ;
70- socket . emit ( 'get-document' , DocId ) ;
60+ socket . emit ( 'get-document' , docId ) ;
7161 socket . once ( 'load-document' , ( data ) => {
7262 setcpp ( data . cpp ) ;
7363 setjava ( data . java ) ;
7464 setpython ( data . python ) ;
7565 } ) ;
7666 // eslint-disable-next-line
77- } , [ socket , DocId ] ) ;
67+ } , [ socket , docId ] ) ;
7868
7969
8070 useEffect ( ( ) => {
@@ -177,10 +167,10 @@ export default function IDE({ modal, toggleModal, python, setpython, input, setI
177167 setUserId ( id ) ;
178168 myVideoCont . id = id ;
179169 myVideoCont . dataset . name = userName ;
180- socket . emit ( 'join-room' , DocId , id ) ;
170+ socket . emit ( 'join-room' , docId , id ) ;
181171 } ) ;
182172 // eslint-disable-next-line
183- } , [ socket , DocId , peer ] ) ;
173+ } , [ socket , docId , peer ] ) ;
184174
185175 const addVideo = useCallback ( ( ) => {
186176 if ( socket == null ) return ;
@@ -243,10 +233,10 @@ export default function IDE({ modal, toggleModal, python, setpython, input, setI
243233 myVideoCont . id = id ;
244234 myVideoCont . dataset . name = userName ;
245235
246- socket . emit ( 'join-room' , DocId , id ) ;
236+ socket . emit ( 'join-room' , docId , id ) ;
247237 } ) ;
248238 // eslint-disable-next-line
249- } , [ socket , DocId , peer ] ) ;
239+ } , [ socket , docId , peer ] ) ;
250240
251241
252242
@@ -624,7 +614,9 @@ function RightVideoPanel({ muteCam, muteMic }) {
624614 < img src = { videoIcon } onClick = { muteCam } alt = "video icon" />
625615 </ button >
626616 < button className = "bg-orange-standard border border-r rounded-full h-8 w-8 p-1.5" >
627- < img src = { phoneIcon } onClick = { muteMic } alt = "phone icon" />
617+ < img src = { phoneIcon } onClick = { ( ) => {
618+ window . location . href = "/"
619+ } } alt = "phone icon" />
628620 </ button >
629621 </ div >
630622 </ div >
0 commit comments